diff options
author | Thomas Gubler <thomasgubler@gmail.com> | 2014-11-24 18:53:08 +0100 |
---|---|---|
committer | Thomas Gubler <thomasgubler@gmail.com> | 2014-11-24 18:53:08 +0100 |
commit | e2f846ee2fb20193ec73e1ea6ebbbd1fa967166e (patch) | |
tree | 47913a751d6e4e042964baac0d2ba473535f17cb /src/platforms/px4_nodehandle.h | |
parent | 1826fa5d39a5feb2a7c044102c899c23c1f12453 (diff) | |
download | px4-firmware-e2f846ee2fb20193ec73e1ea6ebbbd1fa967166e.tar.gz px4-firmware-e2f846ee2fb20193ec73e1ea6ebbbd1fa967166e.tar.bz2 px4-firmware-e2f846ee2fb20193ec73e1ea6ebbbd1fa967166e.zip |
create list of subscribers
Diffstat (limited to 'src/platforms/px4_nodehandle.h')
-rw-r--r-- | src/platforms/px4_nodehandle.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/platforms/px4_nodehandle.h b/src/platforms/px4_nodehandle.h index 809d0eb15..9bbf5c724 100644 --- a/src/platforms/px4_nodehandle.h +++ b/src/platforms/px4_nodehandle.h @@ -40,6 +40,7 @@ #include <px4_subscriber.h> #if defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) #include "ros/ros.h" +#include <list> #endif namespace px4 @@ -48,12 +49,21 @@ namespace px4 class NodeHandle : private ros::NodeHandle { public: + NodeHandle () : + ros::NodeHandle(), + _subs() + {} + template<class M> - Subscriber* subscribe(const char *topic, void(*fp)(M)) { + Subscriber subscribe(const char *topic, void(*fp)(M)) { ros::Subscriber ros_sub = ros::NodeHandle::subscribe(topic, 1000, fp); //XXX create list here, for ros and nuttx - return new Subscriber(ros_sub); + Subscriber sub(ros_sub); + _subs.push_back(sub); + return sub; } +private: + std::list<Subscriber> _subs; }; #else class NodeHandle |