RSB  0.9.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rsb::patterns::RemoteServer Class Reference

The client side of a request-reply-based communication channel. More...

#include <RemoteServer.h>

Inheritance diagram for rsb::patterns::RemoteServer:
Inheritance graph
Collaboration diagram for rsb::patterns::RemoteServer:
Collaboration graph

Classes

class  DataFuture
 
class  DataFuture< void >
 
class  MethodSet
 

Public Types

typedef rsc::threading::Future
< EventPtr
FutureType
 
typedef boost::shared_ptr
< FutureType
FuturePtr
 

Public Member Functions

 RemoteServer (const Scope &scope, const ParticipantConfig &listenerConfig, const ParticipantConfig &informerConfig)
 Construct a new RemoteServer object which can be used to call methods of the server at scope. More...
 
virtual ~RemoteServer ()
 
template<class I >
EventPtr prepareRequestEvent (boost::shared_ptr< I > args)
 Prepares an Event which can be used for a request based on typed data. More...
 
FuturePtr callAsync (const std::string &methodName, EventPtr data)
 Call the method named methodName on the remote server, passing it the event data as argument and returning an event which contains the value returned by the remote method. More...
 
template<typename O , typename I >
DataFuture< O > callAsync (const std::string &methodName, boost::shared_ptr< I > args)
 Call the method named methodName on the remote server, passing it the argument object args and returning the value returned by the remote method. More...
 
template<typename O >
DataFuture< O > callAsync (const std::string &methodName)
 Call the method named methodName on the remote server, without arguments and returning the value returned by the remote method. More...
 
EventPtr call (const std::string &methodName, EventPtr data, unsigned int maxReplyWaitTime=25)
 Call the method named methodName on the remote server, passing it the event data as argument and returning an event which contains the value returned by the remote method. More...
 
template<typename O , typename I >
boost::shared_ptr< O > call (const std::string &methodName, boost::shared_ptr< I > args, unsigned int maxReplyWaitTime=25)
 Call the method named methodName on the remote server, passing it the argument object args and return the value returned by the remote method. More...
 
template<typename O >
boost::shared_ptr< O > call (const std::string &methodName, unsigned int maxReplyWaitTime=25)
 Call the method named methodName on the remote server, without arguments and return the value returned by the remote method. More...
 

Private Member Functions

MethodSet getMethodSet (const std::string &methodName, const std::string &sendType)
 

Private Attributes

rsc::logging::LoggerPtr logger
 
Scope scope
 
ParticipantConfig listenerConfig
 
ParticipantConfig informerConfig
 
boost::mutex methodSetMutex
 
std::map< std::string, MethodSetmethodSets
 

Detailed Description

The client side of a request-reply-based communication channel.

Objects of this class represent remote servers in a way that allows calling methods on them as if they were local.

Author
jwienke
jmoringe

Definition at line 62 of file RemoteServer.h.

Member Typedef Documentation

Definition at line 65 of file RemoteServer.h.

typedef rsc::threading::Future<EventPtr> rsb::patterns::RemoteServer::FutureType

Definition at line 64 of file RemoteServer.h.

Constructor & Destructor Documentation

rsb::patterns::RemoteServer::RemoteServer ( const Scope scope,
const ParticipantConfig listenerConfig,
const ParticipantConfig informerConfig 
)

Construct a new RemoteServer object which can be used to call methods of the server at scope.

Parameters
scopeThe base scope of the server the methods of which will be called.

Definition at line 115 of file RemoteServer.cpp.

rsb::patterns::RemoteServer::~RemoteServer ( )
virtual

Definition at line 129 of file RemoteServer.cpp.

Member Function Documentation

EventPtr rsb::patterns::RemoteServer::call ( const std::string &  methodName,
EventPtr  data,
unsigned int  maxReplyWaitTime = 25 
)

Call the method named methodName on the remote server, passing it the event data as argument and returning an event which contains the value returned by the remote method.

This method blocks until the computation on the remote side has been completed and the result has been received.

Parameters
methodNameName of the method that should be called.
dataAn Event object containing the argument object that should be passed to the called method.
maxReplyWaitTimeMaximum number of seconds to wait for a reply from the server when calling a method.
Returns
An Event object containing the result of the method call.
Exceptions
rsc::threading::FutureTimeoutExceptionif the method call is not completed within the maximum waiting time.
rsc::threading::FutureTaskExecutionExceptionif the method call fails.

Definition at line 197 of file RemoteServer.cpp.

References callAsync().

Here is the call graph for this function:

template<typename O , typename I >
boost::shared_ptr<O> rsb::patterns::RemoteServer::call ( const std::string &  methodName,
boost::shared_ptr< I >  args,
unsigned int  maxReplyWaitTime = 25 
)
inline

Call the method named methodName on the remote server, passing it the argument object args and return the value returned by the remote method.

This method blocks until the computation on the remote side has been completed and the result has been received.

Template Parameters
Itype of the method call argument object.
Otype of the method return value.
Parameters
methodNameName of the method that should be called.
argsThe argument object that should be passed to the called method.
maxReplyWaitTimeMaximum number of seconds to wait for a reply from the server when calling a method.
Returns
The result of the method call.
Exceptions
rsc::threading::FutureTimeoutExceptionif the method call is not completed within the maximum waiting time.
rsc::threading::FutureTaskExecutionExceptionif the method call fails.

Definition at line 210 of file RemoteServer.h.

template<typename O >
boost::shared_ptr<O> rsb::patterns::RemoteServer::call ( const std::string &  methodName,
unsigned int  maxReplyWaitTime = 25 
)
inline

Call the method named methodName on the remote server, without arguments and return the value returned by the remote method.

This method blocks until the computation on the remote side has been completed and the result has been received.

Template Parameters
Otype of the method return value.
Parameters
methodNameName of the method that should be called.
maxReplyWaitTimeMaximum number of seconds to wait for a reply from the server when calling a method.
Returns
The result of the method call.
Exceptions
rsc::threading::FutureTimeoutExceptionif the method call is not completed within the maximum waiting time.
rsc::threading::FutureTaskExecutionExceptionif the method call fails.

Definition at line 235 of file RemoteServer.h.

RemoteServer::FuturePtr rsb::patterns::RemoteServer::callAsync ( const std::string &  methodName,
EventPtr  data 
)

Call the method named methodName on the remote server, passing it the event data as argument and returning an event which contains the value returned by the remote method.

Parameters
methodNameName of the method that should be called.
dataAn Event object containing the argument object that should be passed to the called method.
Returns
A rsc::threading::TimeoutFuture object from which the result (an EventPtr) of the method call can be obtained at the caller's discretion.

Definition at line 176 of file RemoteServer.cpp.

References getMethodSet(), rsb::Participant::getScope(), rsb::patterns::RemoteServer::MethodSet::handler, logger, rsb::Informer< T >::publish(), and rsb::patterns::RemoteServer::MethodSet::requestInformer.

Referenced by call().

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename O , typename I >
DataFuture<O> rsb::patterns::RemoteServer::callAsync ( const std::string &  methodName,
boost::shared_ptr< I >  args 
)
inline

Call the method named methodName on the remote server, passing it the argument object args and returning the value returned by the remote method.

Template Parameters
Itype of the method call argument object.
Otype of the method return value.
Parameters
methodNameName of the method that should be called.
argsThe argument object that should be passed to the called method.
Returns
A DataFuture object from which the result (a shared_ptr to an object of type O) of the method call can be obtained at the caller's discretion.

Definition at line 140 of file RemoteServer.h.

template<typename O >
DataFuture<O> rsb::patterns::RemoteServer::callAsync ( const std::string &  methodName)
inline

Call the method named methodName on the remote server, without arguments and returning the value returned by the remote method.

Template Parameters
Otype of the method return value.
Parameters
methodNameName of the method that should be called.
Returns
A DataFuture object from which the result (a shared_ptr to an object of type O) of the method call can be obtained at the caller's discretion.

Definition at line 157 of file RemoteServer.h.

RemoteServer::MethodSet rsb::patterns::RemoteServer::getMethodSet ( const std::string &  methodName,
const std::string &  sendType 
)
private

Definition at line 132 of file RemoteServer.cpp.

References rsb::Scope::concat(), rsb::Factory::createInformer(), rsb::Factory::createListener(), rsb::getFactory(), informerConfig, listenerConfig, logger, rsb::patterns::RemoteServer::MethodSet::methodName, methodSetMutex, methodSets, and scope.

Referenced by callAsync().

Here is the call graph for this function:

Here is the caller graph for this function:

template<class I >
EventPtr rsb::patterns::RemoteServer::prepareRequestEvent ( boost::shared_ptr< I >  args)
inline

Prepares an Event which can be used for a request based on typed data.

Parameters
argsdata for the event
Template Parameters
Idata type for the data in the event
Returns
event containing the data and appropriate type tags

Definition at line 104 of file RemoteServer.h.

Member Data Documentation

ParticipantConfig rsb::patterns::RemoteServer::informerConfig
private

Definition at line 244 of file RemoteServer.h.

Referenced by getMethodSet().

ParticipantConfig rsb::patterns::RemoteServer::listenerConfig
private

Definition at line 243 of file RemoteServer.h.

Referenced by getMethodSet().

rsc::logging::LoggerPtr rsb::patterns::RemoteServer::logger
private

Definition at line 240 of file RemoteServer.h.

Referenced by callAsync(), and getMethodSet().

boost::mutex rsb::patterns::RemoteServer::methodSetMutex
private

Definition at line 255 of file RemoteServer.h.

Referenced by getMethodSet().

std::map<std::string, MethodSet> rsb::patterns::RemoteServer::methodSets
private

Definition at line 256 of file RemoteServer.h.

Referenced by getMethodSet().

Scope rsb::patterns::RemoteServer::scope
private

Definition at line 242 of file RemoteServer.h.

Referenced by getMethodSet().


The documentation for this class was generated from the following files: