Publisher.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  * Copyright (C) 2014 by Ralf Kaestner                                        *
00003  * ralf.kaestner@gmail.com                                                    *
00004  *                                                                            *
00005  * This program is free software; you can redistribute it and/or modify       *
00006  * it under the terms of the Lesser GNU General Public License as published by*
00007  * the Free Software Foundation; either version 3 of the License, or          *
00008  * (at your option) any later version.                                        *
00009  *                                                                            *
00010  * This program is distributed in the hope that it will be useful,            *
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the               *
00013  * Lesser GNU General Public License for more details.                        *
00014  *                                                                            *
00015  * You should have received a copy of the Lesser GNU General Public License   *
00016  * along with this program. If not, see <http://www.gnu.org/licenses/>.       *
00017  ******************************************************************************/
00018 
00023 #ifndef VARIANT_TOPIC_TOOLS_PUBLISHER_H
00024 #define VARIANT_TOPIC_TOOLS_PUBLISHER_H
00025 
00026 #include <ros/ros.h>
00027 
00028 #include <variant_topic_tools/Forwards.h>
00029 #include <variant_topic_tools/MessageSerializer.h>
00030 #include <variant_topic_tools/MessageType.h>
00031 #include <variant_topic_tools/MessageVariant.h>
00032 
00033 namespace variant_topic_tools {
00036   class Publisher {
00037   friend class MessageType;
00038   public:
00041     Publisher();
00042     
00045     Publisher(const Publisher& src);
00046     
00049     ~Publisher();
00050     
00053     std::string getTopic() const;
00054     
00057     size_t getNumSubscribers() const;
00058     
00061     bool isLatched() const;
00062     
00065     void shutdown();
00066       
00069     inline operator void*() const {
00070       return (impl && impl->isValid()) ? (void*)1 : (void*)0;
00071     };
00072     
00076     void publish(const MessageVariant& variant);
00077   
00081     operator ros::Publisher() const;
00082       
00083   private:
00086     class Impl {
00087     public:
00090       Impl(ros::NodeHandle& nodeHandle, const MessageType& type,
00091         const std::string& topic, size_t queueSize, bool latch = false,
00092         const ros::SubscriberStatusCallback& connectCallback =
00093         ros::SubscriberStatusCallback());
00094       
00097       ~Impl();
00098       
00101       bool isValid() const;
00102       
00105       void shutdown();
00106             
00110       void publish(const MessageVariant& variant);
00111       
00114       MessageType type;
00115       
00118       MessageSerializer serializer;
00119       
00122       uint32_t sequenceNumber;
00123       
00126       ros::Publisher publisher;
00127     };
00128 
00131     typedef boost::shared_ptr<Impl> ImplPtr;
00132     
00136     typedef boost::weak_ptr<Impl> ImplWPtr;
00137     
00140     ImplPtr impl;
00141   };
00142 };
00143 
00144 #endif


variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Fri Aug 5 2016 06:06:27