sas
Modularised monitoring, logging, and control of robots.
Loading...
Searching...
No Matches
sas::ObjectClientManager Class Reference

Manager for multiple ObjectClient instances. More...

#include <sas_object_client_manager.hpp>

Public Member Functions

 ObjectClientManager (const ObjectClientManager &)=delete
ObjectClientManageroperator= (const ObjectClientManager &)=delete
 ObjectClientManager (const std::shared_ptr< rclcpp::Node > &node)
 Construct a new ObjectClientManager.
void add_client (const std::string &name)
 Add (or replace) an ObjectClient identified by a name.
bool remove_client (const std::string &name)
 Remove an ObjectClient by name.
ObjectClientget_client (const std::string &name)
 Get a reference to an existing ObjectClient.
const ObjectClientget_client (const std::string &name) const
 Get a const reference to an existing ObjectClient.
bool has_client (const std::string &name) const
 Check if a client with the given name exists.
std::vector< std::string > get_client_names () const
 Get a list of all managed client names.
size_t size () const
 Get the number of managed clients.
bool are_all_clients_enabled () const
 Check whether all managed clients are enabled.

Detailed Description

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.

Constructor & Destructor Documentation

◆ ObjectClientManager()

sas::ObjectClientManager::ObjectClientManager ( const std::shared_ptr< rclcpp::Node > & node)
explicit

Construct a new ObjectClientManager.

Parameters
nodeShared pointer to the rclcpp::Node used for all managed clients.

Member Function Documentation

◆ 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
nameUnique 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
nameName of the client.
Returns
ObjectClient& Reference to the managed client.
Exceptions
std::runtime_errorif 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
nameName of the client.
Returns
const ObjectClient& Reference to the managed client.
Exceptions
std::runtime_errorif 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
nameName to check.
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
nameName 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: