28 #ifndef ROSCPP_ADVERTISE_SERVICE_OPTIONS_H 29 #define ROSCPP_ADVERTISE_SERVICE_OPTIONS_H 55 template<
class MReq,
class MRes>
56 void init(
const std::string& _service,
const boost::function<
bool(MReq&, MRes&)>& _callback)
58 namespace st = service_traits;
59 namespace mt = message_traits;
60 if (st::md5sum<MReq>() != st::md5sum<MRes>())
62 ROS_FATAL(
"the request and response parameters to the server " 63 "callback function must be autogenerated from the same " 64 "server definition file (.srv). your advertise_servce " 65 "call for %s appeared to use request/response types " 66 "from different .srv files.", service.c_str());
71 md5sum = st::md5sum<MReq>();
73 req_datatype = mt::datatype<MReq>();
74 res_datatype = mt::datatype<MRes>();
75 helper = boost::make_shared<ServiceCallbackHelperT<ServiceSpec<MReq, MRes> > >(_callback);
83 template<
class Service>
84 void init(
const std::string& _service,
const boost::function<
bool(
typename Service::Request&,
typename Service::Response&)>& _callback)
86 namespace st = service_traits;
87 namespace mt = message_traits;
88 typedef typename Service::Request Request;
89 typedef typename Service::Response Response;
91 md5sum = st::md5sum<Service>();
93 req_datatype = mt::datatype<Request>();
94 res_datatype = mt::datatype<Response>();
95 helper = boost::make_shared<ServiceCallbackHelperT<ServiceSpec<Request, Response> > >(_callback);
104 void initBySpecType(
const std::string& _service,
const typename Spec::CallbackType& _callback)
106 namespace st = service_traits;
107 namespace mt = message_traits;
108 typedef typename Spec::RequestType Request;
109 typedef typename Spec::ResponseType Response;
111 md5sum = st::md5sum<Request>();
113 req_datatype = mt::datatype<Request>();
114 res_datatype = mt::datatype<Response>();
115 helper = boost::make_shared<ServiceCallbackHelperT<Spec> >(_callback);
147 template<
class Service>
149 const boost::function<
bool(
typename Service::Request&,
typename Service::Response&)>& callback,
154 ops.
init<
typename Service::Request,
typename Service::Response>(service, callback);
CallbackQueueInterface * callback_queue
Queue to add callbacks to. If NULL, the global callback queue will be used.
std::string md5sum
MD5 of the service.
void init(const std::string &_service, const boost::function< bool(MReq &, MRes &)> &_callback)
Templated convenience method for filling out md5sum/etc. based on the service request/response types...
std::string service
Service name.
VoidConstPtr tracked_object
An object whose destruction will prevent the callback associated with this service from being called...
Abstract interface for a queue used to handle all callbacks within roscpp.
std::string res_datatype
Response message datatype.
Encapsulates all options available for creating a ServiceServer.
ServiceCallbackHelperPtr helper
Helper object used for creating messages and calling callbacks.
void initBySpecType(const std::string &_service, const typename Spec::CallbackType &_callback)
Templated convenience method for filling out md5sum/etc. based on the service spec type...
void init(const std::string &_service, const boost::function< bool(typename Service::Request &, typename Service::Response &)> &_callback)
Templated convenience method for filling out md5sum/etc. based on the service type.
AdvertiseServiceOptions()
static AdvertiseServiceOptions create(const std::string &service, const boost::function< bool(typename Service::Request &, typename Service::Response &)> &callback, const VoidConstPtr &tracked_object, CallbackQueueInterface *queue)
Templated helper function for creating an AdvertiseServiceOptions with all of its options...
std::string datatype
Datatype of the service.
std::string req_datatype
Request message datatype.