REC RPC library
Classes | Namespaces | Macros
rec_rpc_Server.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_Server.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  rec::rpc::RPCFunctionBase
 RPC function wrapper interface. More...
 
struct  rec::rpc::HTTPGetHandlerBase
 HTTP GET handler interface. More...
 
struct  rec::rpc::CustomRequestHandlerBase
 Custom request handler interface. More...
 
class  rec::rpc::Server
 RPC server base class. More...
 

Namespaces

 rec
 
 rec::rpc
 

Macros

#define DECLARE_FUNCTION(FUNCTIONNAME)
 Declare a RPC function in the server class definition. More...
 
#define BEGIN_FUNCTION_DEFINITION(CLASSNAME, FUNCTIONNAME)
 Begin the implementation of a RPC function. More...
 
#define END_FUNCTION_DEFINITION   }
 End of a RPC function implementation. More...
 
#define REGISTER_FUNCTION(FUNCTIONNAME)   registerFunction( #FUNCTIONNAME, create##FUNCTIONNAME##Wrapper() );
 Register a RPC function. More...
 
#define UNREGISTER_FUNCTION(FUNCTIONNAME)   unregisterFunction( #FUNCTIONNAME );
 Unregister a RPC function. More...
 
#define IS_FUNCTION_REGISTERED(FUNCTIONNAME)   isFunctionRegistered( #FUNCTIONNAME );
 Check if a RPC function with a given name is registered. More...
 
#define ADD_TOPIC(TOPICNAME, SHAREDMEMSIZE)   addTopic( #TOPICNAME, SHAREDMEMSIZE );
 Add a topic. More...
 
#define ADD_ENQUEUEDTOPIC(TOPICNAME)   addEnqueuedTopic( #TOPICNAME );
 
#define ADD_SERVERONLY_TOPIC(TOPICNAME, SHAREDMEMSIZE)   addTopic( #TOPICNAME, SHAREDMEMSIZE, true );
 Add a topic. More...
 
#define ADD_PERMANENT_TOPIC(TOPICNAME, SHAREDMEMSIZE)   addPermanentTopic( #TOPICNAME, SHAREDMEMSIZE );
 Add a topic. More...
 
#define ADD_PERMANENT_SERVERONLY_TOPIC(TOPICNAME, SHAREDMEMSIZE)   addPermanentTopic( #TOPICNAME, SHAREDMEMSIZE, true );
 Add a topic. More...
 
#define DECLARE_HTTP_GET_HANDLER(HANDLERNAME)
 Declare a HTTP GET handler in the server class definition. More...
 
#define BEGIN_HTTP_GET_HANDLER_DEFINITION(CLASSNAME, HANDLERNAME)
 Begin the implementation of a HTTP GET handler. More...
 
#define END_HTTP_GET_HANDLER_DEFINITION   }
 End of a HTTP GET handler implementation. More...
 
#define REGISTER_HTTP_GET_HANDLER(HANDLERNAME)   registerHttpGetHandler( create##HANDLERNAME##HttpGetHandler() );
 Register a HTTP GET handler. More...
 
#define REMOVE_HTTP_GET_HANDLER   registerHttpGetHandler( rec::rpc::HTTPGetHandlerBasePtr() );
 Removes the existing HTTP GET handler. More...
 
#define DECLARE_CUSTOM_REQUEST_HANDLER(HANDLERNAME)
 Declare a custom request handler in the server class definition. More...
 
#define BEGIN_CUSTOM_REQUEST_HANDLER_DEFINITION(CLASSNAME, HANDLERNAME)
 Begin the implementation of a custom request handler. More...
 
#define END_CUSTOM_REQUEST_HANDLER_DEFINITION   }
 End of a custom request handler implementation. More...
 
#define REGISTER_CUSTOM_REQUEST_HANDLER(HANDLERNAME)   registerCustomRequestHandler( create##HANDLERNAME##CustomRequestHandler() );
 Register a custom request handler. More...
 
#define REMOVE_CUSTOM_REQUEST_HANDLER   registerCustomRequestHandler( rec::rpc::CustomRequestHandlerBasePtr() );
 Removes the existing custom request handler. More...
 

Macro Definition Documentation

#define ADD_ENQUEUEDTOPIC (   TOPICNAME)    addEnqueuedTopic( #TOPICNAME );

Definition at line 721 of file rec_rpc_Server.h.

#define ADD_PERMANENT_SERVERONLY_TOPIC (   TOPICNAME,
  SHAREDMEMSIZE 
)    addPermanentTopic( #TOPICNAME, SHAREDMEMSIZE, true );

Add a topic.

This macro is used to register a permanent topic in the server. Only the server can publish data via the topic. The data is distributed via shared memory, local IPC or the TCP connection.

Parameters
TOPICNAMEName of the topic.
SHAREDMEMSIZEMinimum size of the shared memory segment in bytes. If 0 (default), no shared memory will be used.
Exceptions
rec::rpc::ExceptionError codes: ImproperTopicName, TopicAlreadyExists.
See also
rec::rpc::Server::addPermanentTopic()

Definition at line 763 of file rec_rpc_Server.h.

#define ADD_PERMANENT_TOPIC (   TOPICNAME,
  SHAREDMEMSIZE 
)    addPermanentTopic( #TOPICNAME, SHAREDMEMSIZE );

Add a topic.

This macro is used to register a permanent topic in the server. The server and the clients can publish data via the topic. The data is distributed via shared memory, local IPC or the TCP connection.

Parameters
TOPICNAMEName of the topic.
SHAREDMEMSIZEMinimum size of the shared memory segment in bytes. If 0 (default), no shared memory will be used.
Exceptions
rec::rpc::ExceptionError codes: ImproperTopicName, TopicAlreadyExists.
See also
rec::rpc::Server::addPermanentTopic()

Definition at line 749 of file rec_rpc_Server.h.

#define ADD_SERVERONLY_TOPIC (   TOPICNAME,
  SHAREDMEMSIZE 
)    addTopic( #TOPICNAME, SHAREDMEMSIZE, true );

Add a topic.

This macro is used to register a non permanent topic in the server. Only the server can publish data via the topic. The data is distributed via shared memory, local IPC or the TCP connection.

Parameters
TOPICNAMEName of the topic.
SHAREDMEMSIZEMinimum size of the shared memory segment in bytes. If 0 (default), no shared memory will be used.
Exceptions
rec::rpc::ExceptionError codes: ImproperTopicName, TopicAlreadyExists.
See also
rec::rpc::Server::addTopic()

Definition at line 735 of file rec_rpc_Server.h.

#define ADD_TOPIC (   TOPICNAME,
  SHAREDMEMSIZE 
)    addTopic( #TOPICNAME, SHAREDMEMSIZE );

Add a topic.

This macro is used to register a non permanent topic in the server. The server and the clients can publish data via the topic. The data is distributed via shared memory, local IPC or the TCP connection.

Parameters
TOPICNAMEName of the topic.
SHAREDMEMSIZEMinimum size of the shared memory segment in bytes. If 0 (default), no shared memory will be used.
Exceptions
rec::rpc::ExceptionError codes: ImproperTopicName, TopicAlreadyExists.
See also
rec::rpc::Server::addTopic()

Definition at line 719 of file rec_rpc_Server.h.

#define BEGIN_CUSTOM_REQUEST_HANDLER_DEFINITION (   CLASSNAME,
  HANDLERNAME 
)
Value:
rec::rpc::CustomRequestHandlerBasePtr CLASSNAME::create##HANDLERNAME##CustomRequestHandler() \
{ \
return rec::rpc::CustomRequestHandlerBasePtr( new rec::rpc::detail::CustomRequestHandler< CLASSNAME >( this, &CLASSNAME::HANDLERNAME ) ); \
} \
void CLASSNAME::HANDLERNAME( const QByteArray& request, QByteArray& response, const rec::rpc::ClientInfo& client ) \
{
RPC client info.

Begin the implementation of a custom request handler.

Place this macro above the implementation of a custom request handler. The "raw" request is accessible via "request", the response must be stored in the QByteArray "response". The IP address and the TCP port of the calling client are accessible via "client" (type rec::rpc::ClientInfo).

Parameters
CLASSNAMEName of your server class.
HANDLERNAMEName of the custom request handler (without qoutes).

Definition at line 848 of file rec_rpc_Server.h.

#define BEGIN_FUNCTION_DEFINITION (   CLASSNAME,
  FUNCTIONNAME 
)
Value:
rec::rpc::RPCFunctionBasePtr CLASSNAME::create##FUNCTIONNAME##Wrapper() \
{ \
return rec::rpc::RPCFunctionBasePtr( new rec::rpc::detail::RPCFunction< CLASSNAME, FUNCTIONNAME##Param, FUNCTIONNAME##Result >( this, &CLASSNAME::FUNCTIONNAME ) ); \
} \
void CLASSNAME::FUNCTIONNAME( const FUNCTIONNAME##Param& param, FUNCTIONNAME##Result& result, const rec::rpc::ClientInfo& client ) \
{
RPC client info.

Begin the implementation of a RPC function.

Place this macro above the implementation of a RPC function. The RPC function parameters are accessible via "param", the return values can be accessed via "result". The types of "param" and "result" are 'FUNCTIONNAME'Param and 'FUNCTIONNAME'Result. These type names must be defined and derived from Serializable. The IP address and the TCP port of the calling client are accessible via "client" (type rec::rpc::ClientInfo).

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

Definition at line 660 of file rec_rpc_Server.h.

#define BEGIN_HTTP_GET_HANDLER_DEFINITION (   CLASSNAME,
  HANDLERNAME 
)
Value:
rec::rpc::HTTPGetHandlerBasePtr CLASSNAME::create##HANDLERNAME##HttpGetHandler() \
{ \
return rec::rpc::HTTPGetHandlerBasePtr( new rec::rpc::detail::HTTPGetHandler< CLASSNAME >( this, &CLASSNAME::HANDLERNAME ) ); \
} \
void CLASSNAME::HANDLERNAME( const QUrl& url, const QString& host, QByteArray& resultPage, QString& contentType, const rec::rpc::ClientInfo& client ) \
{
RPC client info.

Begin the implementation of a HTTP GET handler.

Place this macro above the implementation of a HTTP GET handler. The URL (containing the relative path and the queries) is accessible via the QUrl "url". The host name sent by the client is accessible via the QString "host". The IP address and the TCP port of the calling client are accessible via "client" (type rec::rpc::ClientInfo). The HTML page sent to the client must be stored in the QByteArray "resultPage". Optionally, a content type definition can be specified in the QString "contentType".

Parameters
CLASSNAMEName of your server class.
HANDLERNAMEName of the HTTP GET handler (without qoutes).

Definition at line 791 of file rec_rpc_Server.h.

#define DECLARE_CUSTOM_REQUEST_HANDLER (   HANDLERNAME)
Value:
private: \
rec::rpc::CustomRequestHandlerBasePtr create##HANDLERNAME##CustomRequestHandler(); \
void HANDLERNAME( const QByteArray& request, QByteArray& response, const rec::rpc::ClientInfo& client );
RPC client info.

Declare a custom request handler in the server class definition.

Use this macro to declare a custom request handler in the definition of your own server class derived from rec::rpc::Server. All code which is necessary to register and invoke the handler is inserted automatically.

Parameters
HANDLERNAMEName of the handler function (without qoutes).

Definition at line 833 of file rec_rpc_Server.h.

#define DECLARE_FUNCTION (   FUNCTIONNAME)
Value:
private: \
rec::rpc::RPCFunctionBasePtr create##FUNCTIONNAME##Wrapper(); \
void FUNCTIONNAME( const FUNCTIONNAME##Param& param, FUNCTIONNAME##Result& result, const rec::rpc::ClientInfo& client );
RPC client info.

Declare a RPC function in the server class definition.

Use this macro to declare a RPC function in the definition of your own server class derived from rec::rpc::Server. All code which is necessary to register and invoke the function is inserted automatically.

Parameters
FUNCTIONNAMEName of the RPC function (without qoutes).

Definition at line 644 of file rec_rpc_Server.h.

#define DECLARE_HTTP_GET_HANDLER (   HANDLERNAME)
Value:
private: \
rec::rpc::HTTPGetHandlerBasePtr create##HANDLERNAME##HttpGetHandler(); \
void HANDLERNAME( const QUrl& url, const QString& host, QByteArray& resultPage, QString& contentType, const rec::rpc::ClientInfo& client );
RPC client info.

Declare a HTTP GET handler in the server class definition.

Use this macro to declare a HTTP GET handler in the definition of your own server class derived from rec::rpc::Server. All code which is necessary to register and invoke the handler is inserted automatically.

Parameters
HANDLERNAMEName of the HTTP GET handler function (without qoutes).

Definition at line 773 of file rec_rpc_Server.h.

#define END_CUSTOM_REQUEST_HANDLER_DEFINITION   }

End of a custom request handler implementation.

Definition at line 859 of file rec_rpc_Server.h.

#define END_FUNCTION_DEFINITION   }

End of a RPC function implementation.

Definition at line 671 of file rec_rpc_Server.h.

#define END_HTTP_GET_HANDLER_DEFINITION   }

End of a HTTP GET handler implementation.

Definition at line 802 of file rec_rpc_Server.h.

#define IS_FUNCTION_REGISTERED (   FUNCTIONNAME)    isFunctionRegistered( #FUNCTIONNAME );

Check if a RPC function with a given name is registered.

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

Definition at line 705 of file rec_rpc_Server.h.

#define REGISTER_CUSTOM_REQUEST_HANDLER (   HANDLERNAME)    registerCustomRequestHandler( create##HANDLERNAME##CustomRequestHandler() );

Register a custom request handler.

This method is used to set a handler for custom request requests from a client. It creates the wrapper object and calls registerCustomRequestHandler automatically.

Parameters
HANDLERNAMEName of the handler function.
See also
rec::rpc::Server::registerCustomRequestHandler()

Definition at line 871 of file rec_rpc_Server.h.

#define REGISTER_FUNCTION (   FUNCTIONNAME)    registerFunction( #FUNCTIONNAME, create##FUNCTIONNAME##Wrapper() );

Register a RPC function.

This macro is used to add a RPC function that can be invoked by a client. It creates the wrapper object and calls registerFunction automatically.

Parameters
FUNCTIONNAMEName of the RPC function (without quotes).
Exceptions
rec::rpc::ExceptionError codes: ImproperFunctionName.
See also
rec::rpc::Server::registerFunction()

Definition at line 685 of file rec_rpc_Server.h.

#define REGISTER_HTTP_GET_HANDLER (   HANDLERNAME)    registerHttpGetHandler( create##HANDLERNAME##HttpGetHandler() );

Register a HTTP GET handler.

This method is used to set a handler for HTTP GET requests from a client. It creates the wrapper object and calls registerHttpGetHandler automatically.

Parameters
HANDLERNAMEName of the HTTP GET handler function.
See also
rec::rpc::Server::registerHttpGetHandler()

Definition at line 814 of file rec_rpc_Server.h.

#define REMOVE_CUSTOM_REQUEST_HANDLER   registerCustomRequestHandler( rec::rpc::CustomRequestHandlerBasePtr() );

Removes the existing custom request handler.

This method is used to remove the existing custom request handler.

See also
rec::rpc::Server::registerCustomRequestHandler()

Definition at line 880 of file rec_rpc_Server.h.

#define REMOVE_HTTP_GET_HANDLER   registerHttpGetHandler( rec::rpc::HTTPGetHandlerBasePtr() );

Removes the existing HTTP GET handler.

This method is used to remove the existing HTTP GET handler.

See also
rec::rpc::Server::registerHttpGetHandler()

Definition at line 823 of file rec_rpc_Server.h.

#define UNREGISTER_FUNCTION (   FUNCTIONNAME)    unregisterFunction( #FUNCTIONNAME );

Unregister a RPC function.

This macro is used to remove a RPC function.

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

Definition at line 696 of file rec_rpc_Server.h.