Publisher.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2014 by Ralf Kaestner *
3  * ralf.kaestner@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the Lesser GNU General Public License as published by*
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * Lesser GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the Lesser GNU General Public License *
16  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17  ******************************************************************************/
18 
23 #ifndef VARIANT_TOPIC_TOOLS_PUBLISHER_H
24 #define VARIANT_TOPIC_TOOLS_PUBLISHER_H
25 
26 #include <ros/ros.h>
27 
32 
33 namespace variant_topic_tools {
36  class Publisher {
37  friend class MessageType;
38  public:
41  Publisher();
42 
45  Publisher(const Publisher& src);
46 
49  ~Publisher();
50 
53  std::string getTopic() const;
54 
57  size_t getNumSubscribers() const;
58 
61  bool isLatched() const;
62 
65  void shutdown();
66 
69  inline operator void*() const {
70  return (impl && impl->isValid()) ? (void*)1 : (void*)0;
71  };
72 
76  void publish(const MessageVariant& variant);
77 
81  operator ros::Publisher() const;
82 
83  private:
86  class Impl {
87  public:
91  const std::string& topic, size_t queueSize, bool latch = false,
94 
97  ~Impl();
98 
101  bool isValid() const;
102 
105  void shutdown();
106 
110  void publish(const MessageVariant& variant);
111 
115 
119 
122  uint32_t sequenceNumber;
123 
127  };
128 
132 
136  typedef boost::weak_ptr<Impl> ImplWPtr;
137 
140  ImplPtr impl;
141  };
142 };
143 
144 #endif
void shutdown()
Perform shutdown of the publisher.
Definition: Publisher.cpp:124
void publish(const MessageVariant &variant)
Publish a message variant on the topic associated with this publisher.
Definition: Publisher.cpp:117
boost::function< void(const SingleSubscriberPublisher &)> SubscriberStatusCallback
Variant message publisher.
Definition: Publisher.h:36
Header file providing the MessageSerializer class interface.
uint32_t sequenceNumber
The sequence number associated with this publisher.
Definition: Publisher.h:122
Variant message type information.
Definition: MessageType.h:33
Header file providing forward declarations for the variant topic tools.
Header file providing the MessageVariant class interface.
MessageType type
The message type associated with this publisher.
Definition: Publisher.h:114
boost::shared_ptr< Impl > ImplPtr
Declaration of the publisher implementation pointer type.
Definition: Publisher.h:131
bool isLatched() const
True, if the topic this publisher publishes on is latched.
Definition: Publisher.cpp:97
boost::weak_ptr< Impl > ImplWPtr
Declaration of the publisher implementation weak pointer type.
Definition: Publisher.h:136
void connectCallback(const ros::SingleSubscriberPublisher &)
Definition: relay.cpp:65
size_t getNumSubscribers() const
Retrieve this publisher&#39;s number of subscribers.
Definition: Publisher.cpp:90
Publisher()
Default constructor.
Definition: Publisher.cpp:32
ros::NodeHandlePtr nodeHandle
Definition: echo.cpp:23
Variant message publisher implementation.
Definition: Publisher.h:86
bool isValid() const
True, if this publisher implementation is valid.
Definition: Publisher.cpp:104
void publish(const MessageVariant &variant)
Publish a message variant on the topic associated with this publisher.
Definition: Publisher.cpp:131
ros::Publisher publisher
The ROS publisher.
Definition: Publisher.h:126
ImplPtr impl
The publisher&#39;s implementation.
Definition: Publisher.h:140
std::string getTopic() const
Retrieve the topic this publisher publishes on.
Definition: Publisher.cpp:83
void shutdown()
Perform shutdown of the publisher.
Definition: Publisher.cpp:112
MessageSerializer serializer
The message serializer associated with this publisher.
Definition: Publisher.h:118
Header file providing the MessageType class interface.
Impl(ros::NodeHandle &nodeHandle, const MessageType &type, const std::string &topic, size_t queueSize, bool latch=false, const ros::SubscriberStatusCallback &connectCallback=ros::SubscriberStatusCallback())
Constructor.
Definition: Publisher.cpp:42


variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Sat Jan 9 2021 03:56:50