You must implement the member format() of each class you derive from ostc_ServerOperation. The protocol for this function is defined by ostc_ServerOperation::format().
In order to send the results of execute() to the thin client, the Server converts each return value into one or more ostc_Objects. It does this by calling format() on each return value.
If execute() passed a nonzero void* to ostc_OperationResult::setReturnValue(), the void* is considered to be the only return value. If execute() passed a nonzero os_cursor* to setReturnValue(), each element that can be visited with the cursor is a return value. If execute() passed a nonzero os_collection* to setReturnValue(), each element of the collection is a return value.
void txfer_operation::format( const void * OSobj, ostc_ObjectList * ostcList, ostc_OperationResult*) { Account * acct = (Account*)OSobj; ostc_Object * obj = ostcList->addObject(); obj->setValue("name", acct->getName()); obj->setValue("val", acct->getBalance()); }
ostcList is an empty list of ostc_Objects. format() adds one or more objects to the list (with ostc_ObjectList::addObject()) and sets their attribute values, so that the list ends up containing the object or objects into which OSobj is to be converted.
In this example, a pointer to a float is converted into an ostc_Object with a single attribute, val, whose value is the float. The value is set with ostc_Object::setValue().
Click here for the example in context.
Execution Postprocessing
For nonincremental operations, the Server calls ostc_ServerOperation::operationComplete() when execute() and all associated format() executions complete. For incremental operations, the Server calls ostc_ServerOperation::operationComplete() when execute() and the first batch of associated format() executions complete.