Browse Source

multiplatform: introduce PublisherNode class for uorb for more consistency

sbg
Thomas Gubler 10 years ago
parent
commit
2af44f5995
  1. 6
      src/platforms/px4_nodehandle.h
  2. 18
      src/platforms/px4_publisher.h
  3. 3
      src/platforms/px4_subscriber.h

6
src/platforms/px4_nodehandle.h

@ -176,7 +176,7 @@ public:
} }
/* Empty publications list */ /* Empty publications list */
Publisher *pub = _pubs.getHead(); PublisherNode *pub = _pubs.getHead();
count = 0; count = 0;
while (pub != nullptr) { while (pub != nullptr) {
@ -185,7 +185,7 @@ public:
break; break;
} }
Publisher *sib = pub->getSibling(); PublisherNode *sib = pub->getSibling();
delete pub; delete pub;
pub = sib; pub = sib;
} }
@ -294,7 +294,7 @@ private:
static const uint16_t kMaxSubscriptions = 100; static const uint16_t kMaxSubscriptions = 100;
static const uint16_t kMaxPublications = 100; static const uint16_t kMaxPublications = 100;
List<SubscriberNode *> _subs; /**< Subcriptions of node */ List<SubscriberNode *> _subs; /**< Subcriptions of node */
List<Publisher *> _pubs; /**< Publications of node */ List<PublisherNode *> _pubs; /**< Publications of node */
SubscriberNode *_sub_min_interval; /**< Points to the sub wtih the smallest interval SubscriberNode *_sub_min_interval; /**< Points to the sub wtih the smallest interval
of all Subscriptions in _subs*/ of all Subscriptions in _subs*/
}; };

18
src/platforms/px4_publisher.h

@ -88,9 +88,25 @@ private:
ros::Publisher _ros_pub; /**< Handle to the ros publisher */ ros::Publisher _ros_pub; /**< Handle to the ros publisher */
}; };
#else #else
/**
* Because we maintain a list of publishers we need a node class
*/
class __EXPORT PublisherNode :
public ListNode<PublisherNode *>
{
public:
PublisherNode() :
ListNode()
{}
virtual ~PublisherNode() {}
virtual void update() = 0;
};
class __EXPORT Publisher : class __EXPORT Publisher :
public PublisherBase, public PublisherBase,
public ListNode<Publisher *> public PublisherNode
{ {
public: public:

3
src/platforms/px4_subscriber.h

@ -154,8 +154,6 @@ protected:
}; };
#else // Building for NuttX #else // Building for NuttX
/** /**
* Because we maintain a list of subscribers we need a node class * Because we maintain a list of subscribers we need a node class
*/ */
@ -181,7 +179,6 @@ protected:
}; };
/** /**
* Subscriber class that is templated with the uorb subscription message type * Subscriber class that is templated with the uorb subscription message type
*/ */

Loading…
Cancel
Save