40 #include <boost/bind.hpp> 42 #include <std_msgs/String.h> 52 , data_type_(data_type)
53 , request_data_type_(request_data_type)
54 , response_data_type_(response_data_type)
57 , callback_queue_(callback_queue)
58 , has_tracked_object_(false)
59 , tracked_object_(tracked_object)
92 , num_bytes_(num_bytes)
101 if (link_->getConnection()->isDropped())
113 SerializedMessage res = serialization::serializeServiceResponse<uint32_t>(
false, 0);
114 link_->processResponse(
false, res);
128 link_->processResponse(
true, params.
response);
132 SerializedMessage res = serialization::serializeServiceResponse<uint32_t>(
false, 0);
133 link_->processResponse(
false, res);
136 catch (std::exception& e)
138 ROS_ERROR(
"Exception thrown while processing service call: %s", e.what());
139 std_msgs::String error_string;
140 error_string.data = e.what();
142 link_->processResponse(
false, res);
194 for (V_ServiceClientLink::iterator i = local_links.begin();
195 i != local_links.end(); ++i)
virtual CallResult call()
Call this callback.
ServicePublication(const std::string &name, const std::string &md5sum, const std::string &data_type, const std::string &request_data_type, const std::string &response_data_type, const ServiceCallbackHelperPtr &helper, CallbackQueueInterface *queue, const VoidConstPtr &tracked_object)
CallResult
Possible results for the call() method.
SerializedMessage serializeServiceResponse(bool ok, const M &message)
boost::shared_ptr< M_string > connection_header
void drop()
Terminate this service server.
void dropAllConnections()
boost::mutex client_links_mutex_
SerializedMessage response
Abstract interface for items which can be added to a CallbackQueueInterface.
ServiceCallbackHelperPtr helper_
Abstract interface for a queue used to handle all callbacks within roscpp.
virtual void removeByID(uint64_t owner_id)=0
Remove all callbacks associated with an owner id.
std::vector< ServiceClientLinkPtr > V_ServiceClientLink
ServiceClientLinkPtr link_
SerializedMessage request
CallbackQueueInterface * callback_queue_
VoidConstWPtr tracked_object_
void addServiceClientLink(const ServiceClientLinkPtr &link)
Adds a service link for us to manage.
boost::weak_ptr< void const > VoidConstWPtr
ServiceCallbackHelperPtr helper_
ROSCPP_DECL bool ok()
Check whether it's time to exit.
boost::shared_array< uint8_t > buffer_
virtual void addCallback(const CallbackInterfacePtr &callback, uint64_t owner_id=0)=0
Add a callback, with an optional owner id. The owner id can be used to remove a set of callbacks from...
VoidConstWPtr tracked_object_
V_ServiceClientLink client_links_
void removeServiceClientLink(const ServiceClientLinkPtr &link)
Removes a service link from our list.
ServiceCallback(const ServiceCallbackHelperPtr &helper, const boost::shared_array< uint8_t > &buf, size_t num_bytes, const ServiceClientLinkPtr &link, bool has_tracked_object, const VoidConstWPtr &tracked_object)
void processRequest(boost::shared_array< uint8_t > buf, size_t num_bytes, const ServiceClientLinkPtr &link)
Adds a request to the queue if our thread pool size is not 0, otherwise immediately calls the callbac...