35 #ifndef _ROS_SERVICE_SERVER_H_ 36 #define _ROS_SERVICE_SERVER_H_ 38 #include "rosserial_msgs/TopicInfo.h" 40 #include "ros/publisher.h" 41 #include "ros/subscriber.h" 46 template<
typename MReq ,
typename MRes,
typename ObjT =
void>
47 class ServiceServer :
public Subscriber_
50 typedef void(ObjT::*CallbackT)(
const MReq&, MRes&);
52 ServiceServer(
const char* topic_name, CallbackT cb, ObjT* obj) :
53 pub(topic_name, &resp, rosserial_msgs::TopicInfo::ID_SERVICE_SERVER + rosserial_msgs::TopicInfo::ID_PUBLISHER),
61 virtual void callback(
unsigned char *data)
63 req.deserialize(data);
64 (obj_->*cb_)(req, resp);
67 virtual const char * getMsgType()
69 return this->req.getType();
71 virtual const char * getMsgMD5()
73 return this->req.getMD5();
75 virtual int getEndpointType()
77 return rosserial_msgs::TopicInfo::ID_SERVICE_SERVER + rosserial_msgs::TopicInfo::ID_SUBSCRIBER;
88 template<
typename MReq ,
typename MRes>
92 typedef void(*CallbackT)(
const MReq&, MRes&);
95 pub(topic_name, &resp, rosserial_msgs::TopicInfo::ID_SERVICE_SERVER + rosserial_msgs::TopicInfo::ID_PUBLISHER)
104 req.deserialize(data);
110 return this->req.getType();
114 return this->req.getMD5();
118 return rosserial_msgs::TopicInfo::ID_SERVICE_SERVER + rosserial_msgs::TopicInfo::ID_SUBSCRIBER;
virtual const char * getMsgType()
virtual const char * getMsgMD5()
void publish(const boost::shared_ptr< M > &message) const
ServiceServer(const char *topic_name, CallbackT cb)
virtual int getEndpointType()
virtual void callback(unsigned char *data)