For each class you derive from ostc_ServerOperation, the constructor must do the following:
txfer_operation::txfer_operation() : ostc_ServerOperation("transfer", ostc::isolated_update) { addArgument("from_acct_name", ostc::ostc_string); addArgument("to_acct_name", ostc::ostc_string); addArgument("amount", ostc::ostc_float); addReturnSetAttribute("val", ostc::ostc_float); addReturnSetAttribute("name", ostc::ostc_string); }
"transfer" is the name of the operation. It must be passed to the base type constructor.
Transaction Type
ostc::isolated_update is the type of transaction to use to execute the operation. As with the operation name, it must be passed to the base type constructor. Use this type of transaction for operations that update persistent data. The possible transaction types are
With read_only, mvccRead, and shared_update, requests from different thin clients are batched into the same ObjectStore transaction. This increases throughput by reducing commit overhead.
Important note
Use shared_update only with extreme care. Using shared_update inappropriately can cause incorrect results and database corruption.
An operations that uses the transaction type none must access no persistent data.
Formal Parameters
Each call to addArgument() specifies an argument name and type. These are the same names and types that the thin client must use when setting the actual arguments.
Click here for the example in context.
Type Enumerators
The types are specified with enumerators defined in the scope of the class ostc. The following table shows what type each enumerator signifies:
ostc_int32 | 32-bit integer |
ostc_int64 | 64-bit integer |
ostc_string | char* |
ostc_float | float |
ostc_double | double |
ostc_oid | ostc_OID* (object identifier set by user) |
ostc_binary | void* (for bit streams) |