REC RPC library
Classes | Namespaces | Macros
rec_rpc_Client.h File Reference
#include "rec/rpc/defines.h"
#include "rec/rpc/rec_rpc_common.h"
#include "rec/rpc/rec_rpc_ClientInfo.h"
Include dependency graph for rec_rpc_Client.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  rec::rpc::NotifierBase
 RPC response notifier wrapper interface. More...
 
class  rec::rpc::Client
 RPC client base class. More...
 

Namespaces

 rec
 
 rec::rpc
 

Macros

#define DECLARE_NOTIFIER(FUNCTIONNAME)
 Declare a RPC response notifier in the client class definition. More...
 
#define BEGIN_NOTIFIER(CLASSNAME, FUNCTIONNAME)
 Begin the implementation of a RPC response notifier. More...
 
#define END_NOTIFIER   }
 End of a notifier implementation. More...
 
#define REGISTER_NOTIFIER(FUNCTIONNAME)   registerNotifier( #FUNCTIONNAME, create##FUNCTIONNAME##Notifier() );
 Register a RPC response notifier. More...
 
#define UNREGISTER_NOTIFIER(FUNCTIONNAME)   unregisterNotifier( #FUNCTIONNAME );
 Unregister a RPC response notifier. More...
 
#define IS_NOTIFIER_REGISTERED(FUNCTIONNAME)   isNotifierRegistered( #FUNCTIONNAME );
 Check if a RPC response notifier for a given function name is registered. More...
 
#define PREPARE(FUNCTIONNAME)
 
#define INVOKE(BLOCKING)   invoke( funcName, paramPtr, resultPtr, BLOCKING );
 
#define INVOKE_SIMPLE(FUNCTIONNAME, PARAM, BLOCKING)
 
#define INVOKE_SIMPLE_EMPTY(FUNCTIONNAME, BLOCKING)
 

Macro Definition Documentation

#define BEGIN_NOTIFIER (   CLASSNAME,
  FUNCTIONNAME 
)
Value:
inline rec::rpc::NotifierBasePtr CLASSNAME::create##FUNCTIONNAME##Notifier() \
{ \
return rec::rpc::NotifierBasePtr( new rec::rpc::detail::Notifier< CLASSNAME, FUNCTIONNAME##Result >( this, &CLASSNAME::FUNCTIONNAME##Finished ) ); \
} \
void CLASSNAME::FUNCTIONNAME##Finished( const FUNCTIONNAME##Result& result, rec::rpc::ErrorCode errorCode ) \
{
ErrorCode
Pre-defined error codes.

Begin the implementation of a RPC response notifier.

Place this macro above the implementation of a notifier. The RPC function can be accessed via "result". The type of "result" is 'FUNCTIONNAME'Result. This type name must be defined and derived from Serializable. The error code is accessible via "errorCode".

Parameters
CLASSNAMEName of your client class.
FUNCTIONNAMEName of the RPC function (without qoutes).

Definition at line 491 of file rec_rpc_Client.h.

#define DECLARE_NOTIFIER (   FUNCTIONNAME)
Value:
private: \
rec::rpc::NotifierBasePtr create##FUNCTIONNAME##Notifier(); \
void FUNCTIONNAME##Finished( const FUNCTIONNAME##Result& result, rec::rpc::ErrorCode errorCode );
ErrorCode
Pre-defined error codes.

Declare a RPC response notifier in the client class definition.

Use this macro to declare a response notifier in the definition of your own client class derived from rec::rpc::Client. All code which is necessary to register and invoke the notifier is inserted automatically.

Parameters
FUNCTIONNAMEName of the RPC function (without qoutes).

Definition at line 476 of file rec_rpc_Client.h.

#define END_NOTIFIER   }

End of a notifier implementation.

Definition at line 502 of file rec_rpc_Client.h.

#define INVOKE (   BLOCKING)    invoke( funcName, paramPtr, resultPtr, BLOCKING );

This macro calls invoke() with the appropriate parameters and return values. PREPARE must be above this macro! If BLOCKING is true, the return values are accessible via "result" (a reference to an instance of a class derived from rec::rpc::serialization::Serializable).

Parameters
BLOCKINGIf true, the function call will block until a response has been received from the server. If an error occurs during a blocking function call, a rec::rpc::Exception will be thrown.
Exceptions
rec::rpc::ExceptionError codes: NoConnection, UnknownFunction, WrongDataFormat, ExecutionTimeout, ExecutionCancelled.
See also
PREPARE, INVOKE_SIMPLE, INVOKE_SIMPLE_EMPTY, rec::rpc::Client::invoke()

Definition at line 563 of file rec_rpc_Client.h.

#define INVOKE_SIMPLE (   FUNCTIONNAME,
  PARAM,
  BLOCKING 
)
Value:
FUNCTIONNAME##ResultPtr resultPtr = rec::rpc::detail::createSerializable< FUNCTIONNAME##Result >(); \
FUNCTIONNAME##Result& result = *resultPtr; \
invoke( #FUNCTIONNAME, rec::rpc::detail::createSerializable< FUNCTIONNAME##Param >( PARAM ), resultPtr, BLOCKING );

This macro declares and initializes the parameters and return values for a function call. It can be used if the parameters consist of one single value only. It calls invoke() with the appropriate parameters and return values. If BLOCKING is true, the return values are accessible via "result" (a reference an instance of a class derived from rec::rpc::serialization::Serializable).

Parameters
FUNCTIONNAMEName of the RPC function.
PARAMRPC function parameters.
BLOCKINGIf true, the function call will block until a response has been received from the server. If an error occurs during a blocking function call, a rec::rpc::Exception will be thrown.
Exceptions
rec::rpc::ExceptionError codes: NoConnection, UnknownFunction, WrongDataFormat, ExecutionTimeout, ExecutionCancelled.
See also
PREPARE, INVOKE, INVOKE_SIMPLE_EMPTY, rec::rpc::Client::invoke()

Definition at line 579 of file rec_rpc_Client.h.

#define INVOKE_SIMPLE_EMPTY (   FUNCTIONNAME,
  BLOCKING 
)
Value:
FUNCTIONNAME##ResultPtr resultPtr = rec::rpc::detail::createSerializable< FUNCTIONNAME##Result >(); \
FUNCTIONNAME##Result& result = *resultPtr; \
invoke( #FUNCTIONNAME, rec::rpc::detail::createSerializable< rec::rpc::serialization::Serializable >(), resultPtr, BLOCKING );

This macro declares and initializes the parameters and return values for a function call. It can be used if the function has no parameters. It calls invoke() with the appropriate return values. If BLOCKING is true, the return values are accessible via "result" (a reference to an instance of a class derived from rec::rpc::serialization::Serializable).

Parameters
FUNCTIONNAMEName of the RPC function.
BLOCKINGIf true, the function call will block until a response has been received from the server. If an error occurs during a blocking function call, a rec::rpc::Exception will be thrown.
Exceptions
rec::rpc::ExceptionError codes: NoConnection, UnknownFunction, WrongDataFormat, ExecutionTimeout, ExecutionCancelled.
See also
PREPARE, INVOKE, INVOKE_SIMPLE, rec::rpc::Client::invoke()

Definition at line 597 of file rec_rpc_Client.h.

#define IS_NOTIFIER_REGISTERED (   FUNCTIONNAME)    isNotifierRegistered( #FUNCTIONNAME );

Check if a RPC response notifier for a given function name is registered.

Parameters
FUNCTIONNAMEName of the RPC function (without quotes).
See also
rec::rpc::Client::isNotifierRegistered()

Definition at line 534 of file rec_rpc_Client.h.

#define PREPARE (   FUNCTIONNAME)
Value:
const char* funcName = #FUNCTIONNAME; \
FUNCTIONNAME##ParamPtr paramPtr = rec::rpc::detail::createSerializable< FUNCTIONNAME##Param >(); \
FUNCTIONNAME##Param& param = *paramPtr; \
FUNCTIONNAME##ResultPtr resultPtr = rec::rpc::detail::createSerializable< FUNCTIONNAME##Result >(); \
FUNCTIONNAME##Result& result = *resultPtr;

This macro declares and initializes the parameters and return values for a function call. Below this macro, the parameters can be modified. They are accessible via "param". After adpting the parameters, INVOKE must be called.

Parameters
FUNCTIONNAMEName of the RPC function.
See also
INVOKE, INVOKE_SIMPLE, INVOKE_SIMPLE_EMPTY

Definition at line 545 of file rec_rpc_Client.h.

#define REGISTER_NOTIFIER (   FUNCTIONNAME)    registerNotifier( #FUNCTIONNAME, create##FUNCTIONNAME##Notifier() );

Register a RPC response notifier.

This macro is used to add a notifier that is invoked when the result of a non-blocking function call is ready. It creates the wrapper object and calls registerNotifier automatically.

Parameters
FUNCTIONNAMEName of the RPC function (without quotes).
See also
rec::rpc::Client::registerNotifier()

Definition at line 514 of file rec_rpc_Client.h.

#define UNREGISTER_NOTIFIER (   FUNCTIONNAME)    unregisterNotifier( #FUNCTIONNAME );

Unregister a RPC response notifier.

This macro is used to remove a notifier.

Parameters
FUNCTIONNAMEName of the RPC function (without quotes).
See also
rec::rpc::Client::unregisterNotifier()

Definition at line 525 of file rec_rpc_Client.h.