MessageSubscriber.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  * Copyright (C) 2015 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 
00019 #ifndef RQT_MULTIPLOT_MESSAGE_SUBSCRIBER_H
00020 #define RQT_MULTIPLOT_MESSAGE_SUBSCRIBER_H
00021 
00022 #include <QMap>
00023 #include <QObject>
00024 #include <QString>
00025 #include <QMetaMethod>
00026 
00027 #include <ros/node_handle.h>
00028 
00029 #include <variant_topic_tools/Subscriber.h>
00030 
00031 #include <rqt_multiplot/Message.h>
00032 
00033 namespace rqt_multiplot {
00034   class MessageSubscriber :
00035     public QObject {
00036   Q_OBJECT
00037   public:
00038     enum Property {
00039       QueueSize
00040     };
00041     
00042     MessageSubscriber(QObject* parent = 0, const ros::NodeHandle&
00043       nodeHandle = ros::NodeHandle("~"));
00044     ~MessageSubscriber();
00045     
00046     const ros::NodeHandle& getNodeHandle() const;
00047     void setTopic(const QString& topic);
00048     const QString& getTopic() const;
00049     void setQueueSize(size_t queueSize);
00050     size_t getQueueSize() const;
00051     size_t getNumPublishers() const;  
00052     bool isValid() const;
00053 
00054     bool event(QEvent* event);
00055     
00056   signals:
00057     void subscribed(const QString& topic);
00058     void messageReceived(const QString& topic, const Message& message);
00059     void unsubscribed(const QString& topic);
00060     void aboutToBeDestroyed();
00061   
00062   private:
00063     ros::NodeHandle nodeHandle_;
00064     
00065     QString topic_;
00066     size_t queueSize_;
00067     
00068     variant_topic_tools::Subscriber subscriber_;  
00069       
00070     void subscribe();
00071     void unsubscribe();
00072 
00073     void callback(const variant_topic_tools::MessageVariant& variant,
00074       const ros::Time& receiptTime);
00075 
00076 #if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
00077     void connectNotify(const QMetaMethod& signal);
00078     void disconnectNotify(const QMetaMethod& signal);
00079 #else
00080     void connectNotify(const char* signal);
00081     void disconnectNotify(const char* signal);
00082 #endif
00083   };
00084 };
00085 
00086 #endif


rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Thu Jun 6 2019 21:49:11