service_publication.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008, Morgan Quigley and Willow Garage, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice,
7  * this list of conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution.
11  * * Neither the names of Stanford University or Willow Garage, Inc. nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef ROSCPP_SERVICE_PUBLICATION_H
29 #define ROSCPP_SERVICE_PUBLICATION_H
30 
32 #include "common.h"
33 #include "xmlrpcpp/XmlRpc.h"
34 
35 #include <boost/thread/mutex.hpp>
36 
37 #include <boost/shared_ptr.hpp>
38 #include <boost/shared_array.hpp>
39 #include <boost/thread.hpp>
40 #include <boost/enable_shared_from_this.hpp>
41 
42 #include <vector>
43 #include <queue>
44 
45 namespace ros
46 {
47 
48 class ServiceClientLink;
50 typedef std::vector<ServiceClientLinkPtr> V_ServiceClientLink;
52 
53 class Message;
54 
61 class ROSCPP_DECL ServicePublication : public boost::enable_shared_from_this<ServicePublication>
62 {
63 public:
64  ServicePublication(const std::string& name, const std::string &md5sum, const std::string& data_type, const std::string& request_data_type,
65  const std::string& response_data_type, const ServiceCallbackHelperPtr& helper, CallbackQueueInterface* queue,
66  const VoidConstPtr& tracked_object);
68 
72  void processRequest(boost::shared_array<uint8_t> buf, size_t num_bytes, const ServiceClientLinkPtr& link);
73 
77  void addServiceClientLink(const ServiceClientLinkPtr& link);
81  void removeServiceClientLink(const ServiceClientLinkPtr& link);
82 
86  void drop();
90  bool isDropped() { return dropped_; }
91 
92  const std::string& getMD5Sum() { return md5sum_; }
93  const std::string& getRequestDataType() { return request_data_type_; }
94  const std::string& getResponseDataType() { return response_data_type_; }
95  const std::string& getDataType() { return data_type_; }
96  const std::string& getName() { return name_; }
97 
98 private:
99  void dropAllConnections();
100 
101  std::string name_;
102  std::string md5sum_;
103  std::string data_type_;
104  std::string request_data_type_;
105  std::string response_data_type_;
107 
109  boost::mutex client_links_mutex_;
110 
111  bool dropped_;
112 
116 };
118 
119 }
120 
121 #endif // ROSCPP_SERVICE_PUBLICATION_H
ros::ServicePublication::request_data_type_
std::string request_data_type_
Definition: service_publication.h:104
md5sum
const char * md5sum()
boost::shared_ptr< ServiceClientLink >
ros
ros::ServicePublication::dropped_
bool dropped_
Definition: service_publication.h:111
ros::V_ServiceClientLink
std::vector< ServiceClientLinkPtr > V_ServiceClientLink
Definition: service_publication.h:50
ros::ServicePublication::response_data_type_
std::string response_data_type_
Definition: service_publication.h:105
ros::ServicePublication
Manages an advertised service.
Definition: service_publication.h:61
ros::ServicePublication::getRequestDataType
const std::string & getRequestDataType()
Definition: service_publication.h:93
ros::ServicePublication::md5sum_
std::string md5sum_
Definition: service_publication.h:102
ros::ServicePublication::callback_queue_
CallbackQueueInterface * callback_queue_
Definition: service_publication.h:113
ros::ServicePublication::name_
std::string name_
Definition: service_publication.h:101
ros::ServicePublicationPtr
boost::shared_ptr< ServicePublication > ServicePublicationPtr
Definition: forwards.h:81
ros::ServicePublication::client_links_mutex_
boost::mutex client_links_mutex_
Definition: service_publication.h:109
ros::ServicePublication::getName
const std::string & getName()
Definition: service_publication.h:96
ros::ServicePublication::has_tracked_object_
bool has_tracked_object_
Definition: service_publication.h:114
boost::shared_array< uint8_t >
XmlRpc.h
ros::ServicePublication::tracked_object_
VoidConstWPtr tracked_object_
Definition: service_publication.h:115
ros::VoidConstWPtr
boost::weak_ptr< void const > VoidConstWPtr
Definition: forwards.h:53
ros::ServicePublication::client_links_
V_ServiceClientLink client_links_
Definition: service_publication.h:108
ros::ServicePublication::isDropped
bool isDropped()
Returns whether or not this service server is valid.
Definition: service_publication.h:90
ros::ServicePublication::getDataType
const std::string & getDataType()
Definition: service_publication.h:95
ros::ServicePublication::data_type_
std::string data_type_
Definition: service_publication.h:103
ros::ServicePublication::helper_
ServiceCallbackHelperPtr helper_
Definition: service_publication.h:106
service_callback_helper.h
ros::ServicePublication::getMD5Sum
const std::string & getMD5Sum()
Definition: service_publication.h:92
ros::CallbackQueueInterface
Abstract interface for a queue used to handle all callbacks within roscpp.
Definition: callback_queue_interface.h:82
ros::ServiceClientLinkPtr
boost::shared_ptr< ServiceClientLink > ServiceClientLinkPtr
Definition: service_client_link.h:84
ros::ServicePublication::getResponseDataType
const std::string & getResponseDataType()
Definition: service_publication.h:94


roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas , Jacob Perron
autogenerated on Sat Sep 14 2024 02:59:35