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);