RTC Toolkit 5.0.0
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 <map>
20#include <mutex>
21#include <stdexcept>
22#include <string>
23#include <vector>
24
25namespace rtctk::rtcSupervisor {
26
31public:
32 explicit CommandFailedException(RtcCommand cmd, const std::vector<std::exception_ptr>& errs);
33};
34
46public:
48 explicit RtcObjectController(std::vector<std::unique_ptr<RtcObjectIf>>& objects);
49
50 virtual ~RtcObjectController() = default;
51
69 std::map<std::string, std::string>
70 RunSequential(RtcCommand cmd, bool keep_going, std::optional<unsigned> timeout = std::nullopt);
71
88 std::map<std::string, std::string>
89 RunParallel(RtcCommand cmd, std::optional<unsigned> timeout = std::nullopt);
90
91protected:
92 // cppcheck-suppress-begin unusedStructMember
93
94 log4cplus::Logger& m_logger;
95
97 std::vector<std::unique_ptr<RtcObjectIf>>& m_objects;
98
99 // Mutex to ensure that commands are only sent to the SRTC components being monitored
100 // from one RTC Supervisor thread at a time. Otherwise we might get mixed replies from
101 // two different commands.
102 std::mutex m_command_mutex;
103
104 // cppcheck-suppress-end unusedStructMember
105};
106
107} // namespace rtctk::rtcSupervisor
108
109#endif // RTCTK_RTCSUPERVISOR_RTCOBJECTCONTROLLER_HPP
The RtctkException class is the base class for all Rtctk exceptions.
Definition exceptions.hpp:211
Dedicated exception type to indicate errors.
Definition rtcObjectController.hpp:30
CommandFailedException(RtcCommand cmd, const std::vector< std::exception_ptr > &errs)
Definition rtcObjectController.cpp:34
Class used to control multiple RtcObjects.
Definition rtcObjectController.hpp:45
std::mutex m_command_mutex
Definition rtcObjectController.hpp:102
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:44
log4cplus::Logger & m_logger
Definition rtcObjectController.hpp:94
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:78
std::vector< std::unique_ptr< RtcObjectIf > > & m_objects
reference to lists of objects
Definition rtcObjectController.hpp:97
Logging Support Library based on log4cplus.
elt::mal::future< std::string > InjectReqRepEvent(StateMachineEngine &engine)
Definition malEventInjector.hpp:23
Definition rtcSupervisor.cpp:24
RtcCommand
List of commands that can be issued by the RtcSupervisor.
Definition rtcObject.hpp:55
Handles communication with one supervised RtcComponent.