RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
rtcObjectController.hpp
Go to the documentation of this file.
1
11
12#ifndef RTCTK_RTCSUPERVISOR_RTCOBJECTCONTROLLER_HPP
13#define RTCTK_RTCSUPERVISOR_RTCOBJECTCONTROLLER_HPP
14
17
18#include <map>
19#include <mutex>
20#include <stdexcept>
21#include <string>
22#include <vector>
23
24namespace rtctk::rtcSupervisor {
25
30public:
31 explicit CommandFailedException(RtcCommand cmd, const std::vector<std::exception_ptr>& errs);
32};
33
45public:
47 explicit RtcObjectController(std::vector<std::unique_ptr<RtcObjectIf>>& objects);
48
49 virtual ~RtcObjectController() = default;
50
68 std::map<std::string, std::string>
69 RunSequential(RtcCommand cmd, bool keep_going, std::optional<unsigned> timeout = std::nullopt);
70
87 std::map<std::string, std::string>
88 RunParallel(RtcCommand cmd, std::optional<unsigned> timeout = std::nullopt);
89
90protected:
91 // cppcheck-suppress-begin unusedStructMember
92
93 log4cplus::Logger& m_logger;
94
96 std::vector<std::unique_ptr<RtcObjectIf>>& m_objects;
97
98 // Mutex to ensure that commands are only sent to the SRTC components being monitored
99 // from one RTC Supervisor thread at a time. Otherwise we might get mixed replies from
100 // two different commands.
101 std::mutex m_command_mutex;
102
103 // cppcheck-suppress-end unusedStructMember
104};
105
106} // namespace rtctk::rtcSupervisor
107
108#endif // RTCTK_RTCSUPERVISOR_RTCOBJECTCONTROLLER_HPP
The RtctkException class is the base class for all Rtctk exceptions.
Definition exceptions.hpp:220
CommandFailedException(RtcCommand cmd, const std::vector< std::exception_ptr > &errs)
Definition rtcObjectController.cpp:33
std::mutex m_command_mutex
Definition rtcObjectController.hpp:101
std::map< std::string, std::string > RunSequential(RtcCommand cmd, bool keep_going, std::optional< unsigned > timeout=std::nullopt)
Runs specified command on each object in sequence and waits for completion or error.
Definition rtcObjectController.cpp:43
log4cplus::Logger & m_logger
Definition rtcObjectController.hpp:93
std::map< std::string, std::string > RunParallel(RtcCommand cmd, std::optional< unsigned > timeout=std::nullopt)
Runs specified command on each object in parallel and waits for completion or error.
Definition rtcObjectController.cpp:77
std::vector< std::unique_ptr< RtcObjectIf > > & m_objects
reference to lists of objects
Definition rtcObjectController.hpp:96
RtcCommand
List of commands that can be issued by the RtcSupervisor.
Definition rtcObject.hpp:54
Logging Support Library based on log4cplus.
Definition alertAggregator.cpp:18
Handles communication with one supervised RtcComponent.