RTC Toolkit 4.0.2
Loading...
Searching...
No Matches
rtcObjectController.hpp
Go to the documentation of this file.
1
13#ifndef RTCTK_RTCSUPERVISOR_RTCOBJECTCONTROLLER_HPP
14#define RTCTK_RTCSUPERVISOR_RTCOBJECTCONTROLLER_HPP
15
18
19#include <mutex>
20#include <stdexcept>
21#include <string>
22#include <vector>
23
24namespace rtctk::rtcSupervisor {
25
30public:
31 explicit CommandFailedException(RtcCommand cmd, std::vector<std::exception_ptr> const& errs);
32};
33
45public:
47 RtcObjectController(std::vector<std::unique_ptr<RtcObjectIf>>& objects);
48
49 virtual ~RtcObjectController() = default;
50
66 void
67 RunSequential(RtcCommand cmd, bool keep_going, std::optional<unsigned> timeout = std::nullopt);
68
83 void RunParallel(RtcCommand cmd, std::optional<unsigned> timeout = std::nullopt);
84
85protected:
86 log4cplus::Logger& m_logger;
87
89 std::vector<std::unique_ptr<RtcObjectIf>>& m_objects;
90
91 // Mutex to ensure that commands are only sent to the SRTC components being monitored
92 // from one RTC Supervisor thread at a time. Otherwise we might get mixed replies from
93 // two different commands.
94 std::mutex m_command_mutex;
95};
96
97} // namespace rtctk::rtcSupervisor
98
99#endif // RTCTK_RTCSUPERVISOR_RTCOBJECTCONTROLLER_HPP
The RtctkException class is the base class for all Rtctk exceptions.
Definition: exceptions.hpp:237
Dedicated exception type to indicate errors.
Definition: rtcObjectController.hpp:29
Class used to control multiple RtcObjects.
Definition: rtcObjectController.hpp:44
std::mutex m_command_mutex
Definition: rtcObjectController.hpp:94
void 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
void 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:74
log4cplus::Logger & m_logger
Definition: rtcObjectController.hpp:86
std::vector< std::unique_ptr< RtcObjectIf > > & m_objects
reference to lists of objects
Definition: rtcObjectController.hpp:89
Logging Support Library based on log4cplus.
Definition: rtcSupervisor.cpp:21
RtcCommand
List of commands that can be issued by the RtcSupervisor.
Definition: rtcObject.hpp:51
Handles communication with one supervised RtcComponent.