MethodPacket — structure containing call arguments and results.
class MethodPacket { public: virtual std::string get_argument_value ( int index ) const; }; #define METHOD_PACKET( class_name, method_name ) ... |
Method packets are classes used to keep and serialize method arguments and results and to call methods on the callee node. They are automatically generated from the IDL class descriptions.
Class MethodPacket offers generic interface to all method packet classes. Method get_argument_value is its only method public for the Core user.
This method returns value of given method argument as a string. It uses a textual serialization to generate the string. The argument index is zero-based index into a list of method arguments (0 corresponds to the first argument, 1 to the second one, etc.). To get value of method return type, use -1 as the index.
Massiv::Core::Lib::InvalidArgumentException will be thrown if the index is invalid (lower than or equal to -2, -1 if method does not return a value, or greater than or equal to the number of method arguments.) Undefined value will be returned if the packet has been returned by the create_results() method of ResultObject (i.e. the packet contains method results), and the index corresponds to an in argument.
The METHOD_PACKET macro expands to name of method packet class for given interface and method. For example METHOD_PACKET( Foo, bar ) yields name of method packet for method bar described in the IDL of class Foo.
If you have a MethodPacket pointer to a method packet containing arguments/results of a known method, you can use the METHOD_PACKET macro to cast it to the pointer of the correct type. You can then use this pointer to access method arguments and results directly. All in, out and inout arguments are stored in the method packet object as stype data fields, with names equal to argument names. If the method returns a value, it will be available as _result data field.
See Section 8.5.4, “Getting Reply to Asynchronous RPC” for an example.
If class Foo introduces a virtual method bar, and class Shoo inherits Foo, there will still be only single method packet class for the bar method. METHOD_PACKET( Shoo, bar ) will yield an invalid class name. This is consistent with IDL - you should not (must not) write description of method bar in the IDL description of class Shoo.
Simply, METHOD_PACKET( C, m ) is a valid class name, iff the IDL description of the class C containts a description of method m.