33 #include <boost/shared_ptr.hpp> 34 #include <boost/enable_shared_from_this.hpp> 36 #include <rsc/runtime/TypeStringTools.h> 37 #include <rsc/logging/Logger.h> 39 #include "../Handler.h" 43 #include "rsb/rsbexports.h" 55 public boost::enable_shared_from_this<LocalServer> {
67 virtual EventPtr intlCall(
const std::string& methodName,
92 virtual const std::string& getRequestType()
const;
93 virtual const std::string& getReplyType()
const;
96 const std::string& replyType);
109 template<
class RequestType>
114 = rsc::runtime::typeName(
typeid(RequestType))) :
129 boost::shared_ptr<RequestType> input) = 0;
132 boost::shared_ptr<RequestType> argument
133 = boost::static_pointer_cast<RequestType>(request->getData());
136 reply->setType(result.first);
137 reply->setData(result.second);
151 template<
class RequestType,
class ReplyType>
156 = rsc::runtime::typeName(
typeid(RequestType)),
157 const std::string& replyType
158 = rsc::runtime::typeName(
typeid(ReplyType))) :
172 virtual boost::shared_ptr<ReplyType> call(
const std::string& methodName,
173 boost::shared_ptr<RequestType> input) = 0;
176 boost::shared_ptr<RequestType> argument
177 = boost::static_pointer_cast<RequestType>(request->getData());
178 boost::shared_ptr<ReplyType> result = call(methodName, argument);
180 reply->setType(getReplyType());
181 reply->setData(result);
186 template<
class RequestType>
191 = rsc::runtime::typeName(
typeid(RequestType)),
192 const std::string& replyType
193 = rsc::runtime::typeName(
typeid(
void))) :
206 virtual void call(
const std::string& methodName,
207 boost::shared_ptr<RequestType> input) = 0;
210 boost::shared_ptr<RequestType> argument
211 = boost::static_pointer_cast<RequestType>(request->getData());
212 call(methodName, argument);
214 reply->setType(getReplyType());
215 reply->setData(boost::shared_ptr<void>());
221 template<
class ReplyType>
226 = rsc::runtime::typeName(
typeid(
void)),
227 const std::string& replyType
228 = rsc::runtime::typeName(
typeid(ReplyType))) :
241 virtual boost::shared_ptr<ReplyType> call(
242 const std::string& methodName) = 0;
246 reply->setType(getReplyType());
247 reply->setData(call(methodName));
260 template<
class RequestType,
class ReplyType>
266 typedef boost::function<
267 typename boost::shared_ptr<ReplyType>(
271 const std::string& requestType = rsc::runtime::typeName(
272 typeid(RequestType)),
const std::string& replyType =
273 rsc::runtime::typeName(
typeid(ReplyType))) :
274 CallbackBase(requestType, replyType), function(function) {
279 boost::shared_ptr<RequestType> argument
280 = boost::static_pointer_cast<RequestType>(request->getData());
281 boost::shared_ptr<ReplyType> result =
function(argument);
283 reply->setType(getReplyType());
284 reply->setData(result);
296 template<
class RequestType>
302 typedef boost::function<void(typename boost::shared_ptr<RequestType>)>
FunctionType;
305 const std::string& requestType = rsc::runtime::typeName(
306 typeid(RequestType)),
const std::string& replyType =
307 rsc::runtime::typeName(
typeid(
void))) :
308 CallbackBase(requestType, replyType), function(function) {
313 boost::shared_ptr<RequestType> argument =
314 boost::static_pointer_cast<RequestType>(request->getData());
317 reply->setType(getReplyType());
318 reply->setData(boost::shared_ptr<void>());
330 template<
class ReplyType>
336 typedef boost::function<
340 const std::string& requestType = rsc::runtime::typeName(
341 typeid(
void)),
const std::string& replyType =
342 rsc::runtime::typeName(
typeid(ReplyType))) :
343 CallbackBase(requestType, replyType), function(function) {
349 boost::shared_ptr<ReplyType> result =
function();
351 reply->setType(getReplyType());
352 reply->setData(result);
369 const std::string& name,
372 CallbackPtr callback);
376 virtual std::string getKind()
const;
395 virtual std::string getKind()
const;
398 virtual const std::set<std::string> getTransportURLs()
const;
407 void registerMethod(
const std::string& name, CallbackPtr callback);
413 std::map<std::string, LocalMethodPtr>
methods;
432 rsc::runtime::typeName(typeid(void))) {
443 virtual void call(
const std::string& methodName) = 0;
448 reply->setType(getReplyType());
449 reply->setData(boost::shared_ptr<void>());
470 const std::string& requestType = rsc::runtime::typeName(
471 typeid(
void)),
const std::string& replyType =
472 rsc::runtime::typeName(
typeid(
void))) :
473 LocalServer::
CallbackBase(requestType, replyType), function(
481 reply->setType(getReplyType());
482 reply->setData(boost::shared_ptr<void>());
486 FunctionType
function;
EventPtr intlCall(const std::string &, EventPtr request)
std::pair< std::string, boost::shared_ptr< void > > AnnotatedData
A combination of data type and the actual data.
EventPtr intlCall(const std::string &, EventPtr request)
boost::function< typename boost::shared_ptr< ReplyType >void)> FunctionType
Type of functions that can be accepted.
FunctionCallback(FunctionType function, const std::string &requestType=rsc::runtime::typeName(typeid(RequestType)), const std::string &replyType=rsc::runtime::typeName(typeid(ReplyType)))
boost::shared_ptr< LocalServer > LocalServerPtr
boost::shared_ptr< LocalMethod > LocalMethodPtr
Basic message that is exchanged between informers and listeners.
Callback object used to register one method for a server.
Objects of this class participate in the exchange of notifications on one channel of the bus...
FunctionCallback(FunctionType function, const std::string &requestType=rsc::runtime::typeName(typeid(void)), const std::string &replyType=rsc::runtime::typeName(typeid(void)))
EventPtr intlCall(const std::string &methodName, EventPtr request)
boost::function< void(typename boost::shared_ptr< RequestType >)> FunctionType
Type of functions that can be accepted.
EventPtr intlCall(const std::string &methodName, EventPtr)
Base class for callback classes.
EventPtr intlCall(const std::string &methodName, EventPtr request)
A callback which allows any kind of reply type but is restricted to a single request type...
Callback class with receives and returns events.
AnyReplyTypeCallback(const std::string &requestType=rsc::runtime::typeName(typeid(RequestType)))
Callback(const std::string &requestType=rsc::runtime::typeName(typeid(void)), const std::string &replyType=rsc::runtime::typeName(typeid(ReplyType)))
An adapter to use boost functions for callbacks.
boost::shared_ptr< Listener > ListenerPtr
std::map< std::string, LocalMethodPtr > methods
FunctionCallback(FunctionType function, const std::string &requestType=rsc::runtime::typeName(typeid(void)), const std::string &replyType=rsc::runtime::typeName(typeid(ReplyType)))
boost::function< typename boost::shared_ptr< ReplyType > typename boost::shared_ptr< RequestType >)> FunctionType
Type of functions that can be accepted.
A derived Method class which can be called from the remote side and implements its behavior by invoki...
Callback(const std::string &requestType=rsc::runtime::typeName(typeid(RequestType)), const std::string &replyType=rsc::runtime::typeName(typeid(ReplyType)))
boost::shared_ptr< IntlCallback > CallbackPtr
Callback object interface to implement for registering callable methods.
The server side of a request-reply-based communication channel.
EventPtr intlCall(const std::string &, EventPtr)
Base class for method classes.
boost::function< void(void)> FunctionType
Type of functions that can be accepted.
EventPtr intlCall(const std::string &methodName, EventPtr)
Callback(const std::string &requestType=rsc::runtime::typeName(typeid(RequestType)), const std::string &replyType=rsc::runtime::typeName(typeid(void)))
A class describing the configuration of Participant instances.
FunctionCallback(FunctionType function, const std::string &requestType=rsc::runtime::typeName(typeid(RequestType)), const std::string &replyType=rsc::runtime::typeName(typeid(void)))
EventPtr intlCall(const std::string &, EventPtr)
ParticipantConfig listenerConfig
boost::shared_ptr< Event > EventPtr
Scope is a descriptor for a hierarchical channel of the unified bus.
rsc::logging::LoggerPtr logger
ParticipantConfig informerConfig
EventPtr intlCall(const std::string &methodName, EventPtr request)