58 return service_manager;
61 ServiceManager::ServiceManager()
62 : shutting_down_(false)
91 ROSCPP_LOG_DEBUG(
"ServiceManager::shutdown(): unregistering our advertised services");
112 L_ServiceServerLink::iterator it = local_service_clients.begin();
113 L_ServiceServerLink::iterator end = local_service_clients.end();
114 for (; it != end; ++it)
119 local_service_clients.clear();
137 ROS_ERROR(
"Tried to advertise a service that is already advertised in this node [%s]", ops.
service.c_str());
149 std::snprintf(uri_buf,
sizeof(uri_buf),
"rosrpc://%s:%d",
151 args[2] = string(uri_buf);
173 if((*i)->getName() == serv_name && !(*i)->isDropped())
199 std::snprintf(uri_buf,
sizeof(uri_buf),
"rosrpc://%s:%d",
201 args[2] = string(uri_buf);
203 return master::execute(
"unregisterService", args, result, payload,
false);
210 if (((*s)->getName() == serv_name) && !(*s)->isDropped())
226 if ((*t)->getName() == service)
236 const std::string& request_md5sum,
const std::string& response_md5sum,
247 std::string serv_host;
261 if (transport->connect(serv_host, serv_port))
263 ServiceServerLinkPtr client(boost::make_shared<ServiceServerLink>(service, persistent, request_md5sum, response_md5sum, header_values));
270 client->initialize(connection);
275 ROSCPP_LOG_DEBUG(
"Failed to connect to service [%s] (mapped=[%s]) at [%s:%d]", service.c_str(), service.c_str(), serv_host.c_str(), serv_port);
312 string serv_uri(payload);
313 if (!serv_uri.length())
315 ROS_ERROR(
"lookupService: Empty server URI returned from master");
322 ROS_ERROR(
"lookupService: Bad service uri [%s]", serv_uri.c_str());
CallbackQueueInterface * callback_queue
Queue to add callbacks to. If NULL, the global callback queue will be used.
std::string md5sum
MD5 of the service.
ConnectionManagerPtr connection_manager_
volatile bool shutting_down_
L_ServiceServerLink service_server_links_
ServicePublicationPtr lookupServicePublication(const std::string &service)
Lookup an advertised service.
bool lookupService(const std::string &name, std::string &serv_host, uint32_t &serv_port)
Lookup the host/port of a service.
L_ServicePublication service_publications_
std::string service
Service name.
void removeServiceServerLink(const ServiceServerLinkPtr &client)
Remove the specified service client from our list.
VoidConstPtr tracked_object
An object whose destruction will prevent the callback associated with this service from being called...
ROSCPP_DECL bool splitURI(const std::string &uri, std::string &host, uint32_t &port)
bool unadvertiseService(const std::string &serv_name)
Unadvertise a service.
ROSCPP_DECL const std::string & getName()
Returns the name of the current node.
std::list< ServiceServerLinkPtr > L_ServiceServerLink
PollManagerPtr poll_manager_
boost::function< bool(const ConnectionPtr &, const Header &)> HeaderReceivedFunc
std::string res_datatype
Response message datatype.
Encapsulates all options available for creating a ServiceServer.
std::map< std::string, std::string > M_string
#define ROSCPP_LOG_DEBUG(...)
ServiceCallbackHelperPtr helper
Helper object used for creating messages and calling callbacks.
ROSCPP_DECL const std::string & getHost()
static const ConnectionManagerPtr & instance()
bool advertiseService(const AdvertiseServiceOptions &ops)
ROSCPP_DECL bool execute(const std::string &method, const XmlRpc::XmlRpcValue &request, XmlRpc::XmlRpcValue &response, XmlRpc::XmlRpcValue &payload, bool wait_for_master)
Execute an XMLRPC call on the master.
boost::mutex service_server_links_mutex_
bool unregisterService(const std::string &service)
static const PollManagerPtr & instance()
bool isServiceAdvertised(const std::string &serv_name)
boost::shared_ptr< ServiceServerLink > ServiceServerLinkPtr
static const XMLRPCManagerPtr & instance()
boost::mutex service_publications_mutex_
boost::recursive_mutex shutting_down_mutex_
ServiceServerLinkPtr createServiceServerLink(const std::string &service, bool persistent, const std::string &request_md5sum, const std::string &response_md5sum, const M_string &header_values)
Create a new client to the specified service. If a client to that service already exists...
XMLRPCManagerPtr xmlrpc_manager_
boost::shared_ptr< ServicePublication > ServicePublicationPtr
std::string datatype
Datatype of the service.
std::string req_datatype
Request message datatype.