mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 19:53:33 +08:00
Move uORB::Subscription template implementation to header
This commit is contained in:
committed by
Beat Küng
parent
0dc4f1f96d
commit
3ff1f4d16f
@@ -117,40 +117,6 @@ SubscriptionBase::~SubscriptionBase()
|
||||
if (ret != PX4_OK) { PX4_ERR("orb unsubscribe failed"); }
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Subscription<T>::Subscription(const struct orb_metadata *meta,
|
||||
unsigned interval,
|
||||
int instance,
|
||||
List<SubscriptionNode *> *list) :
|
||||
SubscriptionNode(meta, interval, instance, list),
|
||||
_data() // initialize data structure to zero
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Subscription<T>::Subscription(const Subscription &other) :
|
||||
SubscriptionNode(other._meta, other.getInterval(), other._instance, nullptr),
|
||||
_data() // initialize data structure to zero
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Subscription<T>::~Subscription()
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Subscription<T>::update()
|
||||
{
|
||||
SubscriptionBase::update((void *)(&_data));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool Subscription<T>::check_updated()
|
||||
{
|
||||
return SubscriptionBase::updated();
|
||||
}
|
||||
|
||||
template class __EXPORT Subscription<actuator_armed_s>;
|
||||
template class __EXPORT Subscription<actuator_controls_s>;
|
||||
template class __EXPORT Subscription<att_pos_mocap_s>;
|
||||
|
||||
@@ -171,29 +171,50 @@ public:
|
||||
Subscription(const struct orb_metadata *meta,
|
||||
unsigned interval = 0,
|
||||
int instance = 0,
|
||||
List<SubscriptionNode *> *list = nullptr);
|
||||
List<SubscriptionNode *> *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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user