sas
Modularised monitoring, logging, and control of robots.
Loading...
Searching...
No Matches
sas_object_client_manager.hpp
1#pragma once
2/*
3# Copyright (c) 2026 Murilo Marques Marinho
4#
5# This file is part of sas_common.
6#
7# sas_common is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Lesser General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# sas_common is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Lesser General Public License for more details.
16#
17# You should have received a copy of the GNU Lesser General Public License
18# along with sas_common. If not, see <https://www.gnu.org/licenses/>.
19#
20# ################################################################
21#
22# Author: Murilo M. Marinho, email: murilomarinho@ieee.org
23#
24# ################################################################
25# Contributors:
26# ---
27*/
28
29#include <string>
30#include <unordered_map>
31#include <vector>
32
33#include <rclcpp/rclcpp.hpp>
34
35#include <sas_common/sas_object_client.hpp>
36
37namespace sas
38{
39
48class ObjectClientManager
49{
50private:
51 std::shared_ptr<rclcpp::Node> node_;
52 std::unordered_map<std::string, std::unique_ptr<ObjectClient>> clients_;
53
54public:
55 ObjectClientManager() = delete;
56 ObjectClientManager(const ObjectClientManager&) = delete;
57 ObjectClientManager& operator=(const ObjectClientManager&) = delete;
58
64 explicit ObjectClientManager(const std::shared_ptr<rclcpp::Node>& node);
65
74 void add_client(const std::string& name);
75
82 bool remove_client(const std::string& name);
83
91 ObjectClient& get_client(const std::string& name);
92
100 const ObjectClient& get_client(const std::string& name) const;
101
108 bool has_client(const std::string& name) const;
109
115 std::vector<std::string> get_client_names() const;
116
122 size_t size() const;
123
130 bool are_all_clients_enabled() const;
131};
132
133}
bool are_all_clients_enabled() const
Check whether all managed clients are enabled.
Definition sas_object_client_manager.cpp:91
ObjectClient & get_client(const std::string &name)
Get a reference to an existing ObjectClient.
Definition sas_object_client_manager.cpp:50
bool has_client(const std::string &name) const
Check if a client with the given name exists.
Definition sas_object_client_manager.cpp:70
std::vector< std::string > get_client_names() const
Get a list of all managed client names.
Definition sas_object_client_manager.cpp:75
void add_client(const std::string &name)
Add (or replace) an ObjectClient identified by a name.
Definition sas_object_client_manager.cpp:40
size_t size() const
Get the number of managed clients.
Definition sas_object_client_manager.cpp:86
bool remove_client(const std::string &name)
Remove an ObjectClient by name.
Definition sas_object_client_manager.cpp:45
Client wrapper for object pose.
Definition sas_object_client.hpp:53