Class to store and manage service call handlers. More...
#include <HandlerStorage.hh>
Public Member Functions | |
HandlerStorage ()=default | |
Constructor. | |
virtual | ~HandlerStorage ()=default |
Destructor. | |
void | AddHandler (const std::string &_topic, const std::string &_nUuid, const std::shared_ptr< T > &_handler) |
Add a request handler to a topic. A request handler stores the callback and types associated to a service call request. | |
TopicServiceCalls_M & | AllHandlers () |
Get a reference to all the handlers. | |
bool | FirstHandler (const std::string &_topic, const std::string &_msgTypeName, std::shared_ptr< T > &_handler) const |
Get the first handler for a topic that matches a specific message type. | |
bool | FirstHandler (const std::string &_topic, const std::string &_reqTypeName, const std::string &_repTypeName, std::shared_ptr< T > &_handler) const |
Get the first handler for a topic that matches a specific pair of request/response types. | |
bool | Handler (const std::string &_topic, const std::string &_nUuid, const std::string &_hUuid, std::shared_ptr< T > &_handler) const |
Get a specific handler. | |
bool | Handlers (const std::string &_topic, std::map< std::string, std::map< std::string, std::shared_ptr< T > > > &_handlers) const |
Get the data handlers for a topic. A request handler stores the callback and types associated to a service call request. | |
bool | HasHandlersForNode (const std::string &_topic, const std::string &_nUuid) const |
Check if a node has at least one handler. | |
bool | HasHandlersForTopic (const std::string &_topic) const |
Return true if we have stored at least one request for the topic. | |
bool | RemoveHandler (const std::string &_topic, const std::string &_nUuid, const std::string &_reqUuid) |
Remove a request handler. The node's uuid is used as a key to remove the appropriate request handler. | |
bool | RemoveHandlersForNode (const std::string &_topic, const std::string &_nUuid) |
Remove all the handlers from a given node. | |
Detailed Description
class gz::transport::HandlerStorage< T >
Class to store and manage service call handlers.
Constructor & Destructor Documentation
◆ HandlerStorage()
|
default |
Constructor.
◆ ~HandlerStorage()
|
virtualdefault |
Destructor.
Member Function Documentation
◆ AddHandler()
|
inline |
Add a request handler to a topic. A request handler stores the callback and types associated to a service call request.
- Parameters
-
[in] _topic Topic name. [in] _nUuid Node's unique identifier. [in] _handler Request handler.
References map< K, T >::end(), map< K, T >::find(), map< K, T >::insert(), and std::make_pair().
◆ AllHandlers()
|
inline |
Get a reference to all the handlers.
- Returns
- All the handlers.
◆ FirstHandler() [1/2]
|
inline |
Get the first handler for a topic that matches a specific message type.
- Parameters
-
[in] _topic Topic name. [in] _msgTypeName Type of the msg in string format. [out] _handler handler.
- Returns
- true if a handler was found.
References map< K, T >::at(), map< K, T >::end(), map< K, T >::find(), and gz::transport::kGenericMessageType.
◆ FirstHandler() [2/2]
|
inline |
Get the first handler for a topic that matches a specific pair of request/response types.
- Parameters
-
[in] _topic Topic name. [in] _reqTypeName Type of the service request. [in] _repTypeName Type of the service response. [out] _handler handler.
- Returns
- true if a handler was found.
References map< K, T >::at(), map< K, T >::end(), and map< K, T >::find().
◆ Handler()
|
inline |
Get a specific handler.
- Parameters
-
[in] _topic Topic name. [in] _nUuid Node UUID of the handler. [in] _hUuid Handler UUID. [out] _handler Handler requested.
- Returns
- true if the handler was found.
References map< K, T >::at(), map< K, T >::end(), and map< K, T >::find().
◆ Handlers()
|
inline |
Get the data handlers for a topic. A request handler stores the callback and types associated to a service call request.
- Parameters
-
[in] _topic Topic name. [out] _handlers Request handlers. The key of _handlers is the topic name. The value is another map, where the key is the node UUID and the value is a smart pointer to the handler.
- Returns
- true if the topic contains at least one request.
References map< K, T >::at(), map< K, T >::end(), and map< K, T >::find().
◆ HasHandlersForNode()
|
inline |
Check if a node has at least one handler.
- Parameters
-
[in] _topic Topic name. [in] _nUuid Node's unique identifier.
- Returns
- true if the node has at least one handler registered.
References map< K, T >::at(), map< K, T >::end(), and map< K, T >::find().
◆ HasHandlersForTopic()
|
inline |
Return true if we have stored at least one request for the topic.
- Parameters
-
[in] _topic Topic name.
- Returns
- true if we have stored at least one request for the topic.
References map< K, T >::at(), map< K, T >::empty(), map< K, T >::end(), and map< K, T >::find().
◆ RemoveHandler()
|
inline |
Remove a request handler. The node's uuid is used as a key to remove the appropriate request handler.
- Parameters
-
[in] _topic Topic name. [in] _nUuid Node's unique identifier. [in] _reqUuid Request's UUID to remove.
- Returns
- True when the handler is removed or false otherwise.
References map< K, T >::end(), map< K, T >::erase(), and map< K, T >::find().
◆ RemoveHandlersForNode()
|
inline |
Remove all the handlers from a given node.
- Parameters
-
[in] _topic Topic name. [in] _nUuid Node's unique identifier.
- Returns
- True when at least one handler was removed or false otherwise.
References map< K, T >::end(), map< K, T >::erase(), and map< K, T >::find().
The documentation for this class was generated from the following file: