Subscriber.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_SUBSCRIBER_H
00024 #define VARIANT_TOPIC_TOOLS_SUBSCRIBER_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 Subscriber {
00037   friend class MessageType;
00038   public:
00041     Subscriber();
00042     
00045     Subscriber(const Subscriber& src);
00046     
00049     ~Subscriber();
00050     
00053     std::string getTopic() const;
00054     
00057     size_t getNumPublishers() const;
00058     
00061     void shutdown();
00062       
00065     inline operator void*() const {
00066       return (impl && impl->isValid()) ? (void*)1 : (void*)0;
00067     };
00068     
00072     operator ros::Subscriber() const;
00073       
00074   private:
00077     class Impl {
00078     public:
00081       Impl(ros::NodeHandle& nodeHandle, const MessageType& type, const
00082         std::string& topic, size_t queueSize, const SubscriberCallback&
00083         callback);
00084       
00087       ~Impl();
00088       
00091       bool isValid() const;
00092       
00095       void shutdown();
00096             
00099       void eventCallback(const ros::MessageEvent<Message const>& event);
00100 
00103       MessageType type;
00104       
00107       MessageDataType dataType;
00108       
00111       MessageSerializer serializer;
00112       
00115       SubscriberCallback callback;
00116       
00119       ros::Subscriber subscriber;
00120     };
00121 
00124     typedef boost::shared_ptr<Impl> ImplPtr;
00125     
00129     typedef boost::weak_ptr<Impl> ImplWPtr;
00130     
00133     ImplPtr impl;
00134   };
00135 };
00136 
00137 #endif


variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Tue Jul 9 2019 03:18:42