REC RPC library
Classes | Namespaces | Macros | Functions | Variables
rec_rpc_common.h File Reference
#include "rec/rpc/serialization/rec_rpc_serialization_TopicInfo.h"
#include "rec/rpc/rec_rpc_Exception.h"
#include "rec/rpc/defines.h"
#include <QHostAddress>
Include dependency graph for rec_rpc_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  rec::rpc::TopicListenerBase
 topic listener wrapper interface More...
 

Namespaces

 rec
 
 rec::rpc
 

Macros

#define DECLARE_TOPICLISTENER(TOPICNAME)
 Declare a topic listener in the server or client class definition. More...
 
#define BEGIN_TOPICLISTENER_DEFINITION(CLASSNAME, TOPICNAME)
 Begin the implementation of a topic listener. More...
 
#define END_TOPICLISTENER_DEFINITION   }
 End of a topic listener implementation. More...
 
#define REGISTER_TOPICLISTENER(TOPICNAME)   registerTopicListener( #TOPICNAME, createTopic##TOPICNAME##Listener() );
 Register a topic listener. More...
 
#define UNREGISTER_TOPICLISTENER(TOPICNAME)   unregisterTopicListener( #TOPICNAME );
 Unregister a topic listener. More...
 
#define IS_TOPICLISTENER_REGISTERED(TOPICNAME)   isTopicListenerRegistered( #TOPICNAME );
 Check if a topic listener for a given topic is registered. More...
 
#define DECLARE_TOPICINFOCHANGED(TOPICNAME)
 Declare a topic info listener in the server or client class definition. More...
 
#define BEGIN_TOPICINFOCHANGED_DEFINITION(CLASSNAME, TOPICNAME)
 Begin the implementation of a topic info listener. More...
 
#define END_TOPICINFOCHANGED_DEFINITION   }
 End of a topic info listener implementation. More...
 
#define REGISTER_TOPICINFOCHANGED(TOPICNAME)   registerTopicListener( #TOPICNAME "__info", createTopic##TOPICNAME##InfoChanged() );
 Register a topic info listener. More...
 
#define UNREGISTER_TOPICINFOCHANGED(TOPICNAME)   unregisterTopicListener( #TOPICNAME "__info" );
 Unregister a topic info listener. More...
 
#define IS_TOPICINFOCHANGED_REGISTERED(TOPICNAME)   isTopicListenerRegistered( #TOPICNAME "__info" );
 Check if a topic info listener for a given topic is registered. More...
 
#define PREPARE_TOPIC(TOPICNAME)
 
#define PUBLISH_TOPIC   publishTopic( topicName, dataPtr );
 
#define PUBLISH_TOPIC_SIMPLE(TOPICNAME, DATA)   publishTopic( #TOPICNAME, rec::rpc::detail::createSerializable< topic##TOPICNAME##Data >( DATA ) );
 
#define PUBLISH_TOPIC_SIMPLE_EMPTY(TOPICNAME)   publishTopic( #TOPICNAME, rec::rpc::detail::createSerializable< rec::rpc::serialization::Serializable >() );
 

Functions

REC_RPC_EXPORT int rec::rpc::getLibraryMajorVersion ()
 Get the library's major version. More...
 
REC_RPC_EXPORT int rec::rpc::getLibraryMinorVersion ()
 Get the library's minor version. More...
 
REC_RPC_EXPORT int rec::rpc::getLibraryPatchVersion ()
 Get the library's patch version. More...
 
REC_RPC_EXPORT QString rec::rpc::getLibraryVersionSuffix ()
 Get the library's version suffix. More...
 
REC_RPC_EXPORT int rec::rpc::getLibraryDate ()
 Get the library's version date. More...
 
REC_RPC_EXPORT void rec::rpc::getLibraryVersion (int *major, int *minor, int *patch, QString *suffix, int *date)
 Get the library's version. More...
 
REC_RPC_EXPORT QString rec::rpc::getLibraryVersionString ()
 Get the library's version as string. More...
 

Variables

const int rec::rpc::defaultPort = 9280
 The TCP port which will be used by default if no other one is specified. More...
 

Macro Definition Documentation

#define BEGIN_TOPICINFOCHANGED_DEFINITION (   CLASSNAME,
  TOPICNAME 
)
Value:
void CLASSNAME::set_##TOPICNAME##_info_enabled( bool enable ) \
{ \
if ( enable ) \
{ \
} \
else \
{ \
} \
} \
bool CLASSNAME::is_##TOPICNAME##_info_enabled() const \
{ \
return IS_TOPICINFOCHANGED_REGISTERED( TOPICNAME ); \
} \
inline rec::rpc::TopicListenerBasePtr CLASSNAME::createTopic##TOPICNAME##InfoChanged() \
{ \
return rec::rpc::TopicListenerBasePtr( new rec::rpc::detail::TopicListener< CLASSNAME, rec::rpc::serialization::TopicInfo >( this, &CLASSNAME::topic##TOPICNAME##_infoChanged_raw ) ); \
} \
void CLASSNAME::topic##TOPICNAME##_infoChanged( const rec::rpc::ClientInfoSet& info, rec::rpc::ErrorCode errorCode ) \
{
ErrorCode
Pre-defined error codes.
QSet< ClientInfo > ClientInfoSet
Set of ClientInfos typedef.
#define IS_TOPICINFOCHANGED_REGISTERED(TOPICNAME)
Check if a topic info listener for a given topic is registered.
#define REGISTER_TOPICINFOCHANGED(TOPICNAME)
Register a topic info listener.
#define UNREGISTER_TOPICINFOCHANGED(TOPICNAME)
Unregister a topic info listener.

Begin the implementation of a topic info listener.

Place this macro above the implementation of a topic info listener. The topic info is accessible via "info". Data type is rec::rpc::ClientInfoSet. If an error occurred, the error code is stored in errorCode.

Parameters
CLASSNAMEName of your server or client class.
TOPICNAMEName of the topic (without qoutes).

Definition at line 335 of file rec_rpc_common.h.

#define BEGIN_TOPICLISTENER_DEFINITION (   CLASSNAME,
  TOPICNAME 
)
Value:
void CLASSNAME::set_##TOPICNAME##_enabled( bool enable ) \
{ \
if ( enable ) \
{ \
REGISTER_TOPICLISTENER( TOPICNAME ); \
} \
else \
{ \
} \
} \
bool CLASSNAME::is_##TOPICNAME##_enabled() const \
{ \
return IS_TOPICLISTENER_REGISTERED( TOPICNAME ); \
} \
inline rec::rpc::TopicListenerBasePtr CLASSNAME::createTopic##TOPICNAME##Listener() \
{ \
return rec::rpc::TopicListenerBasePtr( new rec::rpc::detail::TopicListener< CLASSNAME, topic##TOPICNAME##Data >( this, &CLASSNAME::topic##TOPICNAME ) ); \
} \
void CLASSNAME::topic##TOPICNAME( const topic##TOPICNAME##Data& data, const rec::rpc::ClientInfo& client, rec::rpc::ErrorCode errorCode ) \
{
ErrorCode
Pre-defined error codes.
RPC client info.
#define UNREGISTER_TOPICLISTENER(TOPICNAME)
Unregister a topic listener.
#define IS_TOPICLISTENER_REGISTERED(TOPICNAME)
Check if a topic listener for a given topic is registered.
#define REGISTER_TOPICLISTENER(TOPICNAME)
Register a topic listener.

Begin the implementation of a topic listener.

Place this macro above the implementation of a topic listener. The topic data are accessible via "data". The type of "data" is topic<TOPICNAME>Data. This type name 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). If an error occurred, the error code is stored in errorCode.

Parameters
CLASSNAMEName of your server or client class.
TOPICNAMEName of the RPC function (without qoutes).

Definition at line 242 of file rec_rpc_common.h.

#define DECLARE_TOPICINFOCHANGED (   TOPICNAME)
Value:
public: \
void set_##TOPICNAME##_info_enabled( bool enable ); \
bool is_##TOPICNAME##_info_enabled() const; \
private: \
rec::rpc::TopicListenerBasePtr createTopic##TOPICNAME##InfoChanged(); \
void topic##TOPICNAME##_infoChanged_raw( const rec::rpc::serialization::TopicInfo& data, const rec::rpc::ClientInfo& client, rec::rpc::ErrorCode errorCode ) \
{ \
topic##TOPICNAME##_infoChanged( data, errorCode ); \
} \
void topic##TOPICNAME##_infoChanged( const rec::rpc::ClientInfoSet& info, rec::rpc::ErrorCode errorCode );
ErrorCode
Pre-defined error codes.
RPC client info.
QSet< ClientInfo > ClientInfoSet
Set of ClientInfos typedef.
Serialization class for primitive objects and values.

Declare a topic info listener in the server or client class definition.

Use this macro to declare a topic info listener in the definition of your own server or client class derived from rec::rpc::Server or rec::rpc::Client. All code which is necessary to register and invoke the topic listener is inserted automatically. A topic info listener notifies you when a client registers or unregisters a topic listener for a topic.

Parameters
TOPICNAMEName of the topic (without qoutes).

Definition at line 313 of file rec_rpc_common.h.

#define DECLARE_TOPICLISTENER (   TOPICNAME)
Value:
public: \
void set_##TOPICNAME##_enabled( bool enable ); \
bool is_##TOPICNAME##_enabled() const; \
private: \
rec::rpc::TopicListenerBasePtr createTopic##TOPICNAME##Listener(); \
void topic##TOPICNAME( const topic##TOPICNAME##Data& data, const rec::rpc::ClientInfo& client, rec::rpc::ErrorCode errorCode );
ErrorCode
Pre-defined error codes.
RPC client info.

Declare a topic listener in the server or client class definition.

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

Parameters
TOPICNAMEName of the topic (without qoutes).

Definition at line 222 of file rec_rpc_common.h.

#define END_TOPICINFOCHANGED_DEFINITION   }

End of a topic info listener implementation.

Definition at line 361 of file rec_rpc_common.h.

#define END_TOPICLISTENER_DEFINITION   }

End of a topic listener implementation.

Definition at line 268 of file rec_rpc_common.h.

#define IS_TOPICINFOCHANGED_REGISTERED (   TOPICNAME)    isTopicListenerRegistered( #TOPICNAME "__info" );

Check if a topic info listener for a given topic is registered.

Parameters
TOPICNAMEName of the topic (without quotes).
See also
rec::rpc::Client::isTopicListenerRegistered(), rec::rpc::Server::isTopicListenerRegistered()

Definition at line 394 of file rec_rpc_common.h.

#define IS_TOPICLISTENER_REGISTERED (   TOPICNAME)    isTopicListenerRegistered( #TOPICNAME );

Check if a topic listener for a given topic is registered.

Parameters
TOPICNAMEName of the topic (without quotes).
See also
rec::rpc::Client::isTopicListenerRegistered(), rec::rpc::Server::isTopicListenerRegistered()

Definition at line 302 of file rec_rpc_common.h.

#define PREPARE_TOPIC (   TOPICNAME)
Value:
const char* topicName = #TOPICNAME; \
topic##TOPICNAME##DataPtr dataPtr = rec::rpc::detail::createSerializable< topic##TOPICNAME##Data >(); \
topic##TOPICNAME##Data& data = *dataPtr;

This macro declares and initializes the topic data for a topic to be published. Below this macro, the topic data can be modified. It is accessibla via "data". After adpting the topic data, PUBLISH_TOPIC must be called (without parameter).

Parameters
TOPICNAMEName of the topic.
See also
PUBLISH_TOPIC, PUBLISH_TOPIC_SIMPLE

Definition at line 405 of file rec_rpc_common.h.

#define PUBLISH_TOPIC   publishTopic( topicName, dataPtr );

This macro calls publishTopic() with the appropriate topic name and data. PREPARE_TOPIC must be above this macro!

Exceptions
rec::rpc::ExceptionError codes: NoConnection, NoSuchTopic, AccessDenied.
See also
PREPARE_TOPIC, PUBLISH_TOPIC_SIMPLE, rec::rpc::Client::publishTopic(), rec::rpc::Server::publishTopic()

Definition at line 418 of file rec_rpc_common.h.

#define PUBLISH_TOPIC_SIMPLE (   TOPICNAME,
  DATA 
)    publishTopic( #TOPICNAME, rec::rpc::detail::createSerializable< topic##TOPICNAME##Data >( DATA ) );

This macro declares and initializes the topic data for a topic to be published. It can be used if the topic data is only one single value. It calls publishTopic() with the appropriate topic name and data.

Parameters
TOPICNAMEName of the topic.
DATAThe single topic data value.
Exceptions
rec::rpc::ExceptionError codes: NoConnection, NoSuchTopic, AccessDenied.
See also
PREPARE_TOPIC, PUBLISH_TOPIC, rec::rpc::Client::publishTopic(), rec::rpc::Server::publishTopic()

Definition at line 432 of file rec_rpc_common.h.

#define PUBLISH_TOPIC_SIMPLE_EMPTY (   TOPICNAME)    publishTopic( #TOPICNAME, rec::rpc::detail::createSerializable< rec::rpc::serialization::Serializable >() );

Definition at line 434 of file rec_rpc_common.h.

#define REGISTER_TOPICINFOCHANGED (   TOPICNAME)    registerTopicListener( #TOPICNAME "__info", createTopic##TOPICNAME##InfoChanged() );

Register a topic info listener.

This method is used to add a topic info listener that is invoked when a client registers or unregisters a topic listener for a topic.

Parameters
TOPICNAMEName of the topic (without quotes).
Exceptions
rec::rpc::ExceptionError codes: NoSuchTopic.
See also
rec::rpc::Client::registerTopicListener(), rec::rpc::Server::registerTopicListener()

Definition at line 374 of file rec_rpc_common.h.

#define REGISTER_TOPICLISTENER (   TOPICNAME)    registerTopicListener( #TOPICNAME, createTopic##TOPICNAME##Listener() );

Register a topic listener.

This method is used to add a topic listener that is invoked when the data of a topic change. It creates the wrapper object and calls registerTopicListener automatically.

Parameters
TOPICNAMEName of the topic (without quotes).
Exceptions
rec::rpc::ExceptionError codes: NoSuchTopic.
See also
rec::rpc::Client::registerTopicListener(), rec::rpc::Server::registerTopicListener()

Definition at line 282 of file rec_rpc_common.h.

#define UNREGISTER_TOPICINFOCHANGED (   TOPICNAME)    unregisterTopicListener( #TOPICNAME "__info" );

Unregister a topic info listener.

This macro is used to remove a topic info listener.

Parameters
TOPICNAMEName of the topic (without quotes).
See also
rec::rpc::Client::unregisterTopicListener(), rec::rpc::Server::unregisterTopicListener()

Definition at line 385 of file rec_rpc_common.h.

#define UNREGISTER_TOPICLISTENER (   TOPICNAME)    unregisterTopicListener( #TOPICNAME );

Unregister a topic listener.

This macro is used to remove a topic listener.

Parameters
TOPICNAMEName of the topic (without quotes).
See also
rec::rpc::Client::unregisterTopicListener(), rec::rpc::Server::unregisterTopicListener()

Definition at line 293 of file rec_rpc_common.h.