Ticket #88 (new enhancement) — at Initial Version
Zoo kernel interface and encapsulation
Reported by: | Knut Landmark | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | zoo-kernel | Version: | |
Keywords: | Cc: |
Description
Service implementation with Zoo requires specific knowledge about the Zoo kernel. Here are some examples:
- To set or get the value of a parameter, the programmer needs to know that Zoo internally attaches a map struct with the name "value" to the maps struct representing the parameter, e.g.
map* tmp = getMapFromMaps( inputs, "Parameter", "value" );
char* value = tmp->value;
(The map struct named "value" should not be confused with the value field in the map struct.)
- For output data with binary content types, the programmer must know that Zoo attempts to determine the size of the data buffer from a map struct with the name "size", e.g.
int result[4] = { 0, 1, 2, 3 };
char size[16];
snprintf( size, sizeof( size ), "%d", sizeof( output ) );
setMapInMaps( outputs, "Result", "size", size );
setMapInMaps( outputs, "Result", "value", (char *) result );
If the "size" map is missing, Zoo assumes the data is in a text-based format and calls strlen (i.e. searches the for the first 0-byte in the buffer).
- To update the progress status of a process, the programmer must know that the Zoo kernel refers to a map named "status" and a map named "message" in a maps struct named "lenv" in the configuration maps struct, e.g.
char message[] = "Progress: 99 %";
char status[] = "99";
setMapInMaps( conf, "lenv", "status", status );
setMapInMaps( conf, "lenv", "message", message);
updateStatus( conf );
It should be possible to create a new interface that hides the Zoo kernel internal representations from the service implementation. For example, the above code fragments could perhaps be encapsulated in functions with signatures like
char* getInputValue( maps* inputs, const char* parameterName, size_t* numberOfBytes, int* errorCode );
int setOutputValue( maps* outputs, const char* parameterName, char* data, size_t numberOfBytes ); /* return error code */
int updateStatus( maps* config, int percentCompleted, const char* message ); /* return error code */