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
ros
service_manager.h
boost
ros::ServiceManager::instance
static const ServiceManagerPtr & instance()
Definition:
service_manager.cpp:55
ros::ServiceServer::Impl
Definition:
service_server.h:86
ros::ServiceServer::~ServiceServer
~ServiceServer()
Definition:
service_server.cpp:70
ROS_DEBUG
#define ROS_DEBUG(...)
ros::ServiceServer::ServiceServer
ServiceServer()
Definition:
service_server.h:48
ros::NodeHandle
roscpp's interface for creating subscribers, publishers, etc.
Definition:
node_handle.h:85
ros::ServiceServer::getService
std::string getService() const
Definition:
service_server.cpp:82
ros::ServiceServer::impl_
ImplPtr impl_
Definition:
service_server.h:102
ros::ServiceServer::shutdown
void shutdown()
Unadvertise the service associated with this ServiceServer.
Definition:
service_server.cpp:74
ros::ServiceServer
Manages an service advertisement.
Definition:
service_server.h:45
ros::ServiceServer::Impl::unadvertise
void unadvertise()
Definition:
service_server.cpp:48
ros::ServiceServer::Impl::~Impl
~Impl()
Definition:
service_server.cpp:37
ros::ServiceServer::Impl::isValid
bool isValid() const
Definition:
service_server.cpp:43
node_handle.h
ros::ServiceServer::Impl::Impl
Impl()
Definition:
service_server.cpp:35
roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas
, Jacob Perron
autogenerated on Sat Sep 14 2024 02:59:35