src
libros
publisher_link.cpp
Go to the documentation of this file.
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Copyright (c) 2008, Willow Garage, Inc.
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
9
* are met:
10
*
11
* * Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
* * Redistributions in binary form must reproduce the above
14
* copyright notice, this list of conditions and the following
15
* disclaimer in the documentation and/or other materials provided
16
* with the distribution.
17
* * Neither the name of Willow Garage, Inc. nor the names of its
18
* contributors may be used to endorse or promote products derived
19
* from this software without specific prior written permission.
20
*
21
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
* POSSIBILITY OF SUCH DAMAGE.
33
*/
34
35
#include "
ros/publisher_link.h
"
36
#include "
ros/subscription.h
"
37
#include "
ros/header.h
"
38
#include "
ros/connection.h
"
39
#include "
ros/transport/transport.h
"
40
#include "
ros/this_node.h
"
41
#include "
ros/connection_manager.h
"
42
#include "
ros/file_log.h
"
43
44
#include <boost/bind/bind.hpp>
45
46
#include <sstream>
47
48
namespace
ros
49
{
50
51
PublisherLink::PublisherLink
(
const
SubscriptionPtr
& parent,
const
std::string& xmlrpc_uri,
52
const
TransportHints
& transport_hints)
53
: parent_(parent)
54
, connection_id_(0)
55
, publisher_xmlrpc_uri_(xmlrpc_uri)
56
, transport_hints_(transport_hints)
57
, latched_(false)
58
{ }
59
60
PublisherLink::~PublisherLink
()
61
{ }
62
63
bool
PublisherLink::setHeader
(
const
Header
& header)
64
{
65
header
.getValue(
"callerid"
,
caller_id_
);
66
67
std::string
md5sum
, type, latched_str;
68
if
(!
header
.getValue(
"md5sum"
,
md5sum
))
69
{
70
ROS_ERROR
(
"Publisher header did not have required element: md5sum"
);
71
return
false
;
72
}
73
74
md5sum_
=
md5sum
;
75
76
if
(!
header
.getValue(
"type"
, type))
77
{
78
ROS_ERROR
(
"Publisher header did not have required element: type"
);
79
return
false
;
80
}
81
82
latched_
=
false
;
83
if
(
header
.getValue(
"latching"
, latched_str))
84
{
85
if
(latched_str ==
"1"
)
86
{
87
latched_
=
true
;
88
}
89
}
90
91
connection_id_
=
ConnectionManager::instance
()->getNewConnectionID();
92
header_
=
header
;
93
94
if
(
SubscriptionPtr
parent =
parent_
.lock())
95
{
96
parent->headerReceived(shared_from_this(),
header
);
97
}
98
99
return
true
;
100
}
101
102
const
std::string&
PublisherLink::getPublisherXMLRPCURI
()
103
{
104
return
publisher_xmlrpc_uri_
;
105
}
106
107
const
std::string&
PublisherLink::getMD5Sum
()
108
{
109
ROS_ASSERT
(!
md5sum_
.empty());
110
return
md5sum_
;
111
}
112
113
}
// namespace ros
ros::PublisherLink::header_
Header header_
Definition:
publisher_link.h:100
connection_manager.h
this_node.h
md5sum
const char * md5sum()
ros::PublisherLink::getPublisherXMLRPCURI
const std::string & getPublisherXMLRPCURI()
Definition:
publisher_link.cpp:102
ros::PublisherLink::getMD5Sum
const std::string & getMD5Sum()
Definition:
publisher_link.cpp:107
boost::shared_ptr
ros::PublisherLink::caller_id_
std::string caller_id_
Definition:
publisher_link.h:99
ros::PublisherLink::~PublisherLink
virtual ~PublisherLink()
Definition:
publisher_link.cpp:60
ros
ros::PublisherLink::connection_id_
unsigned int connection_id_
Definition:
publisher_link.h:91
ros::Header
ros::TransportHints
Provides a way of specifying network transport hints to ros::NodeHandle::subscribe() and someday ros:...
Definition:
transport_hints.h:54
ros::PublisherLink::latched_
bool latched_
Definition:
publisher_link.h:98
subscription.h
ros::PublisherLink::publisher_xmlrpc_uri_
std::string publisher_xmlrpc_uri_
Definition:
publisher_link.h:92
ros::PublisherLink::md5sum_
std::string md5sum_
Definition:
publisher_link.h:101
connection.h
ros::PublisherLink::parent_
SubscriptionWPtr parent_
Definition:
publisher_link.h:90
publisher_link.h
ROS_ERROR
#define ROS_ERROR(...)
ros::ConnectionManager::instance
static const ConnectionManagerPtr & instance()
Definition:
connection_manager.cpp:43
header.h
transport.h
ros::PublisherLink::setHeader
bool setHeader(const Header &header)
Definition:
publisher_link.cpp:63
header
const std::string header
ros::PublisherLink::PublisherLink
PublisherLink(const SubscriptionPtr &parent, const std::string &xmlrpc_uri, const TransportHints &transport_hints)
Definition:
publisher_link.cpp:51
ROS_ASSERT
#define ROS_ASSERT(cond)
file_log.h
roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas
, Jacob Perron
autogenerated on Sat Sep 14 2024 02:59:35