shape_shifter.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2009, 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 
36 
37 using namespace topic_tools;
38 
39 bool ShapeShifter::uses_old_API_ = false;
40 
41 ShapeShifter::ShapeShifter() : typed(false) {}
42 
44 
45 std::string const& ShapeShifter::getDataType() const { return datatype; }
46 
47 
48 std::string const& ShapeShifter::getMD5Sum() const { return md5; }
49 
50 
51 std::string const& ShapeShifter::getMessageDefinition() const { return msg_def; }
52 
53 
54 void ShapeShifter::morph(const std::string& _md5sum, const std::string& _datatype, const std::string& _msg_def,
55  const std::string& _latching)
56 {
57  md5 = _md5sum;
58  datatype = _datatype;
59  msg_def = _msg_def;
60  latching = _latching;
61  typed = md5 != "*";
62 }
63 
64 
65 ros::Publisher ShapeShifter::advertise(ros::NodeHandle& nh, const std::string& topic, uint32_t queue_size_, bool latch, const ros::SubscriberStatusCallback &connect_cb) const
66 {
67  ros::AdvertiseOptions opts(topic, queue_size_, getMD5Sum(), getDataType(), getMessageDefinition(), connect_cb);
68  opts.latch = latch;
69 
70  return nh.advertise(opts);
71 }
72 
73 
74 uint32_t ShapeShifter::size() const
75 {
76  return msgBuf.size();
77 }
topic_tools::ShapeShifter::getDataType
std::string const & getDataType() const
Definition: shape_shifter.cpp:45
ros::Publisher
topic_tools::ShapeShifter::uses_old_API_
static bool uses_old_API_
Definition: shape_shifter.h:97
topic_tools::ShapeShifter::advertise
ros::Publisher advertise(ros::NodeHandle &nh, const std::string &topic, uint32_t queue_size_, bool latch=false, const ros::SubscriberStatusCallback &connect_cb=ros::SubscriberStatusCallback()) const
Definition: shape_shifter.cpp:65
topic_tools::ShapeShifter::md5
std::string md5
Definition: shape_shifter.h:131
shape_shifter.h
topic_tools::ShapeShifter::datatype
std::string datatype
Definition: shape_shifter.h:131
topic_tools::ShapeShifter::ShapeShifter
ShapeShifter()
Definition: shape_shifter.cpp:41
ros::SubscriberStatusCallback
boost::function< void(const SingleSubscriberPublisher &)> SubscriberStatusCallback
topic_tools::ShapeShifter::latching
std::string latching
Definition: shape_shifter.h:131
ros::NodeHandle::advertise
Publisher advertise(AdvertiseOptions &ops)
ros::AdvertiseOptions
topic_tools::ShapeShifter::~ShapeShifter
virtual ~ShapeShifter()
Definition: shape_shifter.cpp:43
ros::AdvertiseOptions::latch
bool latch
topic_tools::ShapeShifter::typed
bool typed
Definition: shape_shifter.h:132
topic_tools::ShapeShifter::getMD5Sum
std::string const & getMD5Sum() const
Definition: shape_shifter.cpp:48
topic_tools::ShapeShifter::morph
void morph(const std::string &md5sum, const std::string &datatype, const std::string &msg_def, const std::string &latching)
Definition: shape_shifter.cpp:54
topic_tools::ShapeShifter::size
uint32_t size() const
Return the size of the serialized message.
Definition: shape_shifter.cpp:74
topic_tools::ShapeShifter::msgBuf
std::vector< uint8_t > msgBuf
Definition: shape_shifter.h:134
topic_tools
Definition: parse.h:33
topic_tools::ShapeShifter::msg_def
std::string msg_def
Definition: shape_shifter.h:131
ros::NodeHandle
topic_tools::ShapeShifter::getMessageDefinition
std::string const & getMessageDefinition() const
Definition: shape_shifter.cpp:51


topic_tools
Author(s): Morgan Quigley, Brian Gerkey, Dirk Thomas , Jacob Perron
autogenerated on Sat Sep 14 2024 03:00:05