diff options
author | Thomas Gubler <thomasgubler@gmail.com> | 2014-11-25 11:50:35 +0100 |
---|---|---|
committer | Thomas Gubler <thomasgubler@gmail.com> | 2014-11-25 11:50:35 +0100 |
commit | 55cf2fc61c7b90725cd960f9c7d72737024f1cfc (patch) | |
tree | dca32b803a55a4f2154c8fc08d5b6bcfb035c8b7 /src/platforms/px4_nodehandle.h | |
parent | c167df90380fdd99d1b56024c4de104a3f0a2f85 (diff) | |
download | px4-firmware-55cf2fc61c7b90725cd960f9c7d72737024f1cfc.tar.gz px4-firmware-55cf2fc61c7b90725cd960f9c7d72737024f1cfc.tar.bz2 px4-firmware-55cf2fc61c7b90725cd960f9c7d72737024f1cfc.zip |
WIP, towards more px4 compatibility, first macros
Diffstat (limited to 'src/platforms/px4_nodehandle.h')
-rw-r--r-- | src/platforms/px4_nodehandle.h | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/platforms/px4_nodehandle.h b/src/platforms/px4_nodehandle.h index d66884445..fa2c8d6a4 100644 --- a/src/platforms/px4_nodehandle.h +++ b/src/platforms/px4_nodehandle.h @@ -49,21 +49,26 @@ #include <inttypes.h> #else /* includes when building for NuttX */ - +#include <containers/List.hpp> #endif namespace px4 { #if defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) -class NodeHandle : private ros::NodeHandle +class NodeHandle : + private ros::NodeHandle { public: - NodeHandle () : + NodeHandle() : ros::NodeHandle(), _subs(), _pubs() {} + ~NodeHandle() { + //XXX empty lists + }; + template<typename M> Subscriber subscribe(const char *topic, void(*fp)(M)) { ros::Subscriber ros_sub = ros::NodeHandle::subscribe(topic, kQueueSizeDefault, fp); @@ -87,6 +92,30 @@ private: #else class NodeHandle { +public: + NodeHandle() : + _subs(), + _pubs() + {} + + ~NodeHandle() {}; + + template<typename M> + Subscriber subscribe(const char *topic, void(*fp)(M)) { + Subscriber sub(&_subs, , interval); + return sub; + } + + template<typename M> + Publisher advertise(const char *topic) { + Publisher pub(ros_pub); + _pubs.push_back(pub); + return pub; + } +private: + List<Subscriber> _subs; + List<Publisher> _pubs; + }; #endif } |