Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
libros
service_server.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2009, 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
#include "
ros/service_server.h
"
29
#include "
ros/node_handle.h
"
30
#include "
ros/service_manager.h
"
31
32
namespace
ros
33
{
34
35
ServiceServer::Impl::Impl
() : unadvertised_(false) { }
36
37
ServiceServer::Impl::~Impl
()
38
{
39
ROS_DEBUG
(
"ServiceServer on '%s' deregistering callbacks."
,
service_
.c_str());
40
unadvertise
();
41
}
42
43
bool
ServiceServer::Impl::isValid
()
const
44
{
45
return
!
unadvertised_
;
46
}
47
48
void
ServiceServer::Impl::unadvertise
()
49
{
50
if
(!
unadvertised_
)
51
{
52
unadvertised_
=
true
;
53
ServiceManager::instance
()->unadvertiseService(
service_
);
54
node_handle_
.reset();
55
}
56
}
57
58
ServiceServer::ServiceServer
(
const
std::string& service,
const
NodeHandle
& node_handle)
59
:
impl_
(
boost
::make_shared<
Impl
>())
60
{
61
impl_
->service_ = service;
62
impl_
->node_handle_ = boost::make_shared<NodeHandle>(node_handle);
63
}
64
65
ServiceServer::ServiceServer
(
const
ServiceServer
& rhs)
66
{
67
impl_
= rhs.
impl_
;
68
}
69
70
ServiceServer::~ServiceServer
()
71
{
72
}
73
74
void
ServiceServer::shutdown
()
75
{
76
if
(
impl_
)
77
{
78
impl_
->unadvertise();
79
}
80
}
81
82
std::string
ServiceServer::getService
()
const
83
{
84
if
(
impl_
&&
impl_
->isValid())
85
{
86
return
impl_
->service_;
87
}
88
89
return
std::string();
90
}
91
92
}
// namespace ros
service_server.h
boost
ros::ServiceServer::Impl::node_handle_
NodeHandlePtr node_handle_
Definition:
service_server.h:95
ros::ServiceServer::Impl::unadvertised_
bool unadvertised_
Definition:
service_server.h:96
ros::ServiceServer::Impl::unadvertise
void unadvertise()
Definition:
service_server.cpp:48
service_manager.h
ros::ServiceServer::Impl::~Impl
~Impl()
Definition:
service_server.cpp:37
ros::ServiceManager::instance
static const ServiceManagerPtr & instance()
Definition:
service_manager.cpp:55
ros::ServiceServer::Impl::Impl
Impl()
Definition:
service_server.cpp:35
ros::ServiceServer::Impl
Definition:
service_server.h:85
node_handle.h
ros::NodeHandle
roscpp's interface for creating subscribers, publishers, etc.
Definition:
node_handle.h:87
ros::ServiceServer::getService
std::string getService() const
Definition:
service_server.cpp:82
ros::ServiceServer::~ServiceServer
~ServiceServer()
Definition:
service_server.cpp:70
ros::ServiceServer::ServiceServer
ServiceServer()
Definition:
service_server.h:48
ros::ServiceServer::shutdown
void shutdown()
Unadvertise the service associated with this ServiceServer.
Definition:
service_server.cpp:74
ros::ServiceServer::Impl::service_
std::string service_
Definition:
service_server.h:94
ros
ros::ServiceServer
Manages an service advertisement.
Definition:
service_server.h:45
ros::ServiceServer::impl_
ImplPtr impl_
Definition:
service_server.h:101
ros::ServiceServer::Impl::isValid
bool isValid() const
Definition:
service_server.cpp:43
ROS_DEBUG
#define ROS_DEBUG(...)
roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim
autogenerated on Sun Feb 3 2019 03:29:54