mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 10:53:34 +08:00
Added Dispatcher type usage methods: hasPublisher(), hasSubscriber(), hasServer()
This commit is contained in:
@@ -33,6 +33,18 @@ void Dispatcher::ListenerRegister::remove(TransferListenerBase* listener)
|
||||
list_.remove(listener);
|
||||
}
|
||||
|
||||
bool Dispatcher::ListenerRegister::exists(DataTypeID dtid) const
|
||||
{
|
||||
TransferListenerBase* p = list_.get();
|
||||
while (p)
|
||||
{
|
||||
if (p->getDataTypeDescriptor().getID() == dtid)
|
||||
return true;
|
||||
p = p->getNextListNode();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Dispatcher::ListenerRegister::cleanup(MonotonicTime ts)
|
||||
{
|
||||
TransferListenerBase* p = list_.get();
|
||||
@@ -188,6 +200,22 @@ void Dispatcher::unregisterServiceResponseListener(TransferListenerBase* listene
|
||||
lsrv_resp_.remove(listener);
|
||||
}
|
||||
|
||||
bool Dispatcher::hasSubscriber(DataTypeID dtid) const
|
||||
{
|
||||
return lmsg_.exists(dtid);
|
||||
}
|
||||
|
||||
bool Dispatcher::hasPublisher(DataTypeID dtid) const
|
||||
{
|
||||
return outgoing_transfer_reg_.exists(dtid, TransferTypeMessageBroadcast)
|
||||
|| outgoing_transfer_reg_.exists(dtid, TransferTypeMessageUnicast);
|
||||
}
|
||||
|
||||
bool Dispatcher::hasServer(DataTypeID dtid) const
|
||||
{
|
||||
return lsrv_req_.exists(dtid);
|
||||
}
|
||||
|
||||
bool Dispatcher::setNodeID(NodeID nid)
|
||||
{
|
||||
if (nid.isUnicast() && !self_node_id_.isValid())
|
||||
|
||||
Reference in New Issue
Block a user