Implementing execute()

ostc_ServerOperation::execute()

virtual void execute(
      ostc_Object * arguments, 
      ostc_OperationResult* result
) = 0;

For each operation you want a Server to handle, you must define a subtype of ostc_ServerOperation, and implement the member execute() (among other functions). The component Server calls this function in response to thin client calls to ostc_Session::doOperation() for the operation.

ostc_ServerOperation::execute() is a pure virtual that specifies the protocol for the function you must implement.

The function must extract the arguments by calling a get-value member of ostc_Object on arguments, for each attribute of arguments.

It must then process the arguments and set the result (in the form of C++ objects) by performing members of ostc_OperationResult on result.

The Server calls this function within an ObjectStore transaction. You do not have to start a transaction explicitly in order to access persistent data within this function.

Your implementation of execute() must be reentrant. That is, you are responsible for synchronizing access to any transient state that could be shared across Server threads. In addition, for operations that use shared_update transactions, you must synchronize access to persistent data if that is necessary to prevent interference among threads.

Click here for an example.



[previous] [next]