[Top] [Prev] [Next] [Bottom] [Contents]

Adding Population Callbacks to the Tool

Sapphire/Web is a very flexible tool. Because it allows the developer to write C/C++ code throughout the project and to add object files and libraries to the makefile, many things can be accomplished.

However, adding the same Population Callback object file to the project over and over again can get tedious, and typing a custom callback name into the Results Detail Dialog is prone to error. These issues have been addressed. The following section discusses how to add Population Callbacks to Sapphire/Web.

Step 1 - Write and Test

It is important that your Population Callback works just the way you expected it to before making it a part of the tool, especially if you will be sharing the changes with other developers. One way to aid in this is to use the examples provided in the $SAPPHIRE/client/src/SaHtmlC.c file.

SaHtmlC.c has source for every Population Callback delivered with the tool. They have been written to work cross-platform, cross-language and as efficiently as possible. Use them as reference, or even copy them and make your adjustments.

Step 2 - Add to List of Callbacks

To make your Population Callback appear in the List of Callbacks in the Results Detail Dialog, you need to append it to $SAPPHIRE/config/PopCalls.list. When Sapphire/Web is shipped, the PopCalls.list file contains all of the Population Callbacks delivered with the tool. The Population Callbacks must appear one per line. Blank lines are ignored as well as those that start with a #.

Step 3 - Decide Between Object Files and Libraries

Decide if you want your Population Callbacks to be linked into your server applications as Object Code or Libraries. It makes no difference which you choose; however a library archive has one advantage. If you want to add more object files to the library at a later date, you need only to add them to the archive and can skip the remaining steps.

Step 4 - Modify The Makefile Template

When projects are generated, the makefile created is read from the $SAPPHIRE/config/Makefile.tem file. Then the placeholders in that file are replaced with project-specific information. Some of the placeholders are for Project Options associated with the makefile.

To link your Population Callbacks into every server application, locate the second occurrence of the SA_LIBS variable, and place your library or object file immediately before $(SA_LIBS) on the link line. Example:

Before:

$(LD) $(LD_FLAGS) $(OBJS) $(APPL_LIBS) $(SA_LIBS) 
$(SYSTEM_LIBS) $(LIBS) $(XOPEN_LIBS) -o $(EXECUTABLE)
After:

$(LD) $(LD_FLAGS) $(OBJS) $(APPL_LIBS) 
/usr/local/bin/mylib.a $(SA_LIBS) $(SYSTEM_LIBS) 
$(LIBS) $(XOPEN_LIBS) -o $(EXECUTABLE)


[Top] [Prev] [Next] [Bottom] [Contents]

info@bluestone.com
Copyright © 1997, Bluestone. All rights reserved.