ServiceClient<>::getCallIDByIndex()

This commit is contained in:
Pavel Kirienko
2015-05-24 15:59:32 +03:00
parent 4f64e2378e
commit 8729d6a2d6
2 changed files with 19 additions and 0 deletions
@@ -341,6 +341,12 @@ public:
*/
bool hasPendingCallToServer(NodeID server_node_id) const;
/**
* This method allows to traverse pending calls. If the index is out of range, an invalid call ID will be returned.
* Warning: average complexity is O(index); worst case complexity is O(size).
*/
ServiceCallID getCallIDByIndex(unsigned index) const;
/**
* Service response callback must be set prior service call.
*/
@@ -556,6 +562,13 @@ bool ServiceClient<DataType_, Callback_, NumStaticCalls_>::hasPendingCallToServe
return NULL != call_registry_.find(ServerSearchPredicate(server_node_id));
}
template <typename DataType_, typename Callback_, unsigned NumStaticCalls_>
ServiceCallID ServiceClient<DataType_, Callback_, NumStaticCalls_>::getCallIDByIndex(unsigned index) const
{
const CallState* const id = call_registry_.getByIndex(index);
return (id == NULL) ? ServiceCallID() : id->getCallID();
}
}
#endif // UAVCAN_NODE_SERVICE_CLIENT_HPP_INCLUDED