Manager for multiple ObjectClient instances.
More...
#include <sas_object_client_manager.hpp>
Manager for multiple ObjectClient instances.
The ObjectClientManager maintains a named collection of ObjectClient objects. Each client is identified by a unique string name, which also serves as its topic prefix. Clients are created lazily from a shared rclcpp::Node.
◆ ObjectClientManager()
| sas::ObjectClientManager::ObjectClientManager |
( |
const std::shared_ptr< rclcpp::Node > & | node | ) |
|
|
explicit |
Construct a new ObjectClientManager.
- Parameters
-
| node | Shared pointer to the rclcpp::Node used for all managed clients. |
◆ add_client()
| void sas::ObjectClientManager::add_client |
( |
const std::string & | name | ) |
|
Add (or replace) an ObjectClient identified by a name.
The name is used as the topic prefix for the client. If a client with the same name already exists, it will be replaced.
- Parameters
-
| name | Unique identifier and topic prefix for the client. |
◆ are_all_clients_enabled()
| bool sas::ObjectClientManager::are_all_clients_enabled |
( |
| ) |
const |
Check whether all managed clients are enabled.
- Returns
- true if every managed client reports is_enabled() == true, or if no clients are managed; false otherwise.
◆ get_client() [1/2]
| ObjectClient & sas::ObjectClientManager::get_client |
( |
const std::string & | name | ) |
|
Get a reference to an existing ObjectClient.
- Parameters
-
- Returns
- ObjectClient& Reference to the managed client.
- Exceptions
-
| std::runtime_error | if no client with the given name exists. |
◆ get_client() [2/2]
| const ObjectClient & sas::ObjectClientManager::get_client |
( |
const std::string & | name | ) |
const |
Get a const reference to an existing ObjectClient.
- Parameters
-
- Returns
- const ObjectClient& Reference to the managed client.
- Exceptions
-
| std::runtime_error | if no client with the given name exists. |
◆ get_client_names()
| std::vector< std::string > sas::ObjectClientManager::get_client_names |
( |
| ) |
const |
Get a list of all managed client names.
- Returns
- std::vector<std::string> Vector of client names.
◆ has_client()
| bool sas::ObjectClientManager::has_client |
( |
const std::string & | name | ) |
const |
Check if a client with the given name exists.
- Parameters
-
- Returns
- true if a client with the name is managed, false otherwise.
◆ remove_client()
| bool sas::ObjectClientManager::remove_client |
( |
const std::string & | name | ) |
|
Remove an ObjectClient by name.
- Parameters
-
| name | Name of the client to remove. |
- Returns
- true if the client was found and removed, false otherwise.
◆ size()
| size_t sas::ObjectClientManager::size |
( |
| ) |
const |
Get the number of managed clients.
- Returns
- size_t Number of clients currently managed.
The documentation for this class was generated from the following files: