From 3ff1f4d16f54ec58e842a258c106f4a406579058 Mon Sep 17 00:00:00 2001 From: Julien Lecoeur Date: Tue, 13 Jun 2017 01:14:49 +0200 Subject: [PATCH] Move uORB::Subscription template implementation to header --- src/modules/uORB/Subscription.cpp | 34 ------------------------------- src/modules/uORB/Subscription.hpp | 33 ++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 40 deletions(-) diff --git a/src/modules/uORB/Subscription.cpp b/src/modules/uORB/Subscription.cpp index fb59b4e85e..d720e60d4c 100644 --- a/src/modules/uORB/Subscription.cpp +++ b/src/modules/uORB/Subscription.cpp @@ -117,40 +117,6 @@ SubscriptionBase::~SubscriptionBase() if (ret != PX4_OK) { PX4_ERR("orb unsubscribe failed"); } } -template -Subscription::Subscription(const struct orb_metadata *meta, - unsigned interval, - int instance, - List *list) : - SubscriptionNode(meta, interval, instance, list), - _data() // initialize data structure to zero -{ -} - -template -Subscription::Subscription(const Subscription &other) : - SubscriptionNode(other._meta, other.getInterval(), other._instance, nullptr), - _data() // initialize data structure to zero -{ -} - -template -Subscription::~Subscription() -{ -} - -template -void Subscription::update() -{ - SubscriptionBase::update((void *)(&_data)); -} - -template -bool Subscription::check_updated() -{ - return SubscriptionBase::updated(); -} - template class __EXPORT Subscription; template class __EXPORT Subscription; template class __EXPORT Subscription; diff --git a/src/modules/uORB/Subscription.hpp b/src/modules/uORB/Subscription.hpp index 599dcf33f8..dba289db1f 100644 --- a/src/modules/uORB/Subscription.hpp +++ b/src/modules/uORB/Subscription.hpp @@ -171,29 +171,50 @@ public: Subscription(const struct orb_metadata *meta, unsigned interval = 0, int instance = 0, - List *list = nullptr); + List *list = nullptr): + SubscriptionNode(meta, interval, instance, list), + _data() // initialize data structure to zero + {} + + + Subscription(const Subscription &other): + SubscriptionNode(other._meta, other.getInterval(), other._instance, nullptr), + _data() // initialize data structure to zero + {} - Subscription(const Subscription & /*other*/); /** * Deconstructor */ - virtual ~Subscription(); + virtual ~Subscription() + {} /** * Create an update function that uses the embedded struct. */ - void update(); + void update() + { + SubscriptionBase::update((void *)(&_data)); + } + /** * Create an update function that uses the embedded struct. */ - bool check_updated(); + bool check_updated() + { + return SubscriptionBase::updated(); + } + /* * This function gets the T struct data * */ - const T &get() const { return _data; } + const T &get() const + { + return _data; + } + private: T _data; };