diff options
author | Thomas Gubler <thomasgubler@gmail.com> | 2015-01-21 16:33:19 +0100 |
---|---|---|
committer | Thomas Gubler <thomasgubler@gmail.com> | 2015-01-21 16:33:19 +0100 |
commit | 1511fd7b2dd19e0ae4c63553cbaf00e2a753148f (patch) | |
tree | 805c055f2aea86d3ca550a7bf33e5396d3c893e5 | |
parent | 52a2a23cc77cff300d0c73f66a450fc1a8fccd5a (diff) | |
download | px4-firmware-1511fd7b2dd19e0ae4c63553cbaf00e2a753148f.tar.gz px4-firmware-1511fd7b2dd19e0ae4c63553cbaf00e2a753148f.tar.bz2 px4-firmware-1511fd7b2dd19e0ae4c63553cbaf00e2a753148f.zip |
make handle() static
-rw-r--r-- | src/platforms/nuttx/px4_messages/px4_rc_channels.h | 2 | ||||
-rw-r--r-- | src/platforms/px4_message.h | 3 | ||||
-rw-r--r-- | src/platforms/px4_nodehandle.h | 10 | ||||
-rw-r--r-- | src/platforms/ros/px4_messages/px4_rc_channels.h | 2 |
4 files changed, 7 insertions, 10 deletions
diff --git a/src/platforms/nuttx/px4_messages/px4_rc_channels.h b/src/platforms/nuttx/px4_messages/px4_rc_channels.h index cb1135eb9..2ce7bfc80 100644 --- a/src/platforms/nuttx/px4_messages/px4_rc_channels.h +++ b/src/platforms/nuttx/px4_messages/px4_rc_channels.h @@ -20,7 +20,7 @@ public: ~px4_rc_channels() {} - PX4TopicHandle handle() {return (PX4TopicHandle)ORB_ID(rc_channels);} + static PX4TopicHandle handle() {return ORB_ID(rc_channels);} }; } diff --git a/src/platforms/px4_message.h b/src/platforms/px4_message.h index c908f6fc6..bff7aa313 100644 --- a/src/platforms/px4_message.h +++ b/src/platforms/px4_message.h @@ -42,7 +42,7 @@ typedef const char* PX4TopicHandle; #else #include <uORB/uORB.h> -typedef const struct orb_metatdata* PX4TopicHandle; +typedef orb_id_t PX4TopicHandle; #endif namespace px4 @@ -70,7 +70,6 @@ public: virtual M& data() {return _data;} virtual const M& data() const {return _data;} - virtual PX4TopicHandle handle() = 0; private: M _data; }; diff --git a/src/platforms/px4_nodehandle.h b/src/platforms/px4_nodehandle.h index 2406a4a77..5ae4f9325 100644 --- a/src/platforms/px4_nodehandle.h +++ b/src/platforms/px4_nodehandle.h @@ -93,7 +93,7 @@ public: Subscriber<T> *subscribe(void(*fp)(const T &)) { SubscriberBase *sub = new SubscriberROS<T>(std::bind(fp, std::placeholders::_1)); - ros::Subscriber ros_sub = ros::NodeHandle::subscribe((new T())->handle(), kQueueSizeDefault, + ros::Subscriber ros_sub = ros::NodeHandle::subscribe(T::handle(), kQueueSizeDefault, &SubscriberROS<T>::callback, (SubscriberROS<T> *)sub); ((SubscriberROS<T> *)sub)->set_ros_sub(ros_sub); _subs.push_back(sub); @@ -147,7 +147,7 @@ public: Publisher* advertise() // Publisher<T> *advertise() { - ros::Publisher ros_pub = ros::NodeHandle::advertise<typename std::remove_reference<decltype(((T*)nullptr)->data())>::type &>((new T())->handle(), kQueueSizeDefault); + ros::Publisher ros_pub = ros::NodeHandle::advertise<typename std::remove_reference<decltype(((T*)nullptr)->data())>::type &>(T::handle(), kQueueSizeDefault); Publisher *pub = new Publisher(ros_pub); _pubs.push_back(pub); return pub; @@ -245,8 +245,7 @@ public: // Subscriber<T> *subscribe(void(*fp)(const typename std::remove_reference<decltype(((T*)nullptr)->data())>::type &), unsigned interval=10) //XXX interval Subscriber<T> *subscribe(void(*fp)(const T &), unsigned interval=10) //XXX interval { - const struct orb_metadata * meta = NULL; - uORB::SubscriptionBase * uorb_sub = new uORB::SubscriptionBase(meta, interval); + uORB::SubscriptionBase * uorb_sub = new uORB::SubscriptionBase(T::handle(), interval); // SubscriberUORBCallback<T> *sub_px4 = new SubscriberUORBCallback<T>(uorb_sub, interval, callback); SubscriberUORBCallback<T> *sub_px4 = new SubscriberUORBCallback<T>(uorb_sub, interval, std::bind(fp, std::placeholders::_1)); @@ -300,8 +299,7 @@ public: { //XXX // uORB::PublicationBase * uorb_pub = new uORB::PublicationBase((new T())->handle()); - const struct orb_metadata * meta = NULL; - uORB::PublicationBase * uorb_pub = new uORB::PublicationBase(meta); + uORB::PublicationBase * uorb_pub = new uORB::PublicationBase(T::handle()); Publisher *pub = new Publisher(uorb_pub); _pubs.add(pub); diff --git a/src/platforms/ros/px4_messages/px4_rc_channels.h b/src/platforms/ros/px4_messages/px4_rc_channels.h index a5a5ee202..5e9dc72cd 100644 --- a/src/platforms/ros/px4_messages/px4_rc_channels.h +++ b/src/platforms/ros/px4_messages/px4_rc_channels.h @@ -19,7 +19,7 @@ public: ~px4_rc_channels() {} - PX4TopicHandle handle() {return "rc_channels";} + static PX4TopicHandle handle() {return "rc_channels";} }; } |