RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
rtcObject.hpp
Go to the documentation of this file.
1
11
12#ifndef RTCTK_RTCSUPERVISOR_RTCOBJECT_HPP
13#define RTCTK_RTCSUPERVISOR_RTCOBJECT_HPP
14
16
17#include <Rtctkif.hpp>
18#include <Stdif.hpp>
19
20#include <optional>
21#include <string>
22
23#include <fmt/format.h>
24
25namespace rtctk::rtcSupervisor {
26
34 // cppcheck-suppress-begin unusedStructMember
35
37 std::string name;
38
40 std::string rr_uri;
41
43 std::string ps_uri;
44
45 // cppcheck-suppress-end unusedStructMember
46};
47
67
75public:
76 virtual ~RtcObjectIf() = default;
77
83 virtual RtcObjectInfo GetInfo() const = 0;
84
90 virtual void RunAsync(RtcCommand cmd) = 0;
91
98 virtual std::string WaitAsync(std::optional<unsigned> timeout) = 0;
99};
100
107class RtcObject : public RtcObjectIf {
108public:
114 explicit RtcObject(const RtcObjectInfo& obj_info);
115 ~RtcObject() override = default;
116 RtcObjectInfo GetInfo() const override;
117 void RunAsync(RtcCommand cmd) override;
118 std::string WaitAsync(std::optional<unsigned> timeout) override;
119
120private:
121 // cppcheck-suppress-begin unusedStructMember
122
123 log4cplus::Logger& m_logger;
124
126 RtcObjectInfo m_info;
127 // reference to the name for convenience purpose
128 const std::string& m_name;
129
131 std::shared_ptr<stdif::StdCmdsAsync> m_stdif_async;
132 std::shared_ptr<rtctkif::UpdateCmdsAsync> m_ucif_async;
133 std::shared_ptr<rtctkif::AlertCmdsAsync> m_acif_async;
134 std::shared_ptr<rtctkif::RecoverCmdsAsync> m_rcif_async;
135
137 elt::mal::future<std::string> m_reply_future;
138
139 // cppcheck-suppress-end unusedStructMember
140};
141
142} // namespace rtctk::rtcSupervisor
143
150template <>
151struct fmt::formatter<rtctk::rtcSupervisor::RtcCommand> : formatter<string_view> {
152 template <typename FormatContext>
153 auto format(rtctk::rtcSupervisor::RtcCommand c, FormatContext& ctx) const {
154 string_view name = "unknown";
155 switch (c) {
157 name = "STOP";
158 break;
160 name = "INIT";
161 break;
163 name = "RESET";
164 break;
166 name = "ENABLE";
167 break;
169 name = "DISABLE";
170 break;
172 name = "EXIT";
173 break;
175 name = "GET_STATE";
176 break;
178 name = "GET_VERSION";
179 break;
181 name = "UPDATE";
182 break;
184 name = "CLEAR_ALERTS";
185 break;
187 name = "RECOVER";
188 break;
189 }
190 return formatter<string_view>::format(name, ctx);
191 } // format
192}; // struct fmt::formatter
193
194#endif // RTCTK_RTCSUPERVISOR_RTCOBJECT_HPP
Interface class for RtcObject.
Definition rtcObject.hpp:74
virtual std::string WaitAsync(std::optional< unsigned > timeout)=0
Weits for a previously started command request to conclude.
virtual void RunAsync(RtcCommand cmd)=0
Starts an async command request.
virtual RtcObjectInfo GetInfo() const =0
Get basic object information.
RtcObjectInfo GetInfo() const override
Get basic object information.
Definition rtcObject.cpp:116
void RunAsync(RtcCommand cmd) override
Starts an async command request.
Definition rtcObject.cpp:120
~RtcObject() override=default
RtcObject(const RtcObjectInfo &obj_info)
Constructor for default RtcObject.
Definition rtcObject.cpp:58
std::string WaitAsync(std::optional< unsigned > timeout) override
Weits for a previously started command request to conclude.
Definition rtcObject.cpp:178
RtcCommand
List of commands that can be issued by the RtcSupervisor.
Definition rtcObject.hpp:54
@ UPDATE
Definition rtcObject.hpp:63
@ GET_VERSION
Definition rtcObject.hpp:62
@ STOP
Definition rtcObject.hpp:55
@ GET_STATE
Definition rtcObject.hpp:61
@ EXIT
Definition rtcObject.hpp:60
@ ENABLE
Definition rtcObject.hpp:58
@ RESET
Definition rtcObject.hpp:57
@ RECOVER
Definition rtcObject.hpp:65
@ CLEAR_ALERTS
Definition rtcObject.hpp:64
@ INIT
Definition rtcObject.hpp:56
@ DISABLE
Definition rtcObject.hpp:59
Logging Support Library based on log4cplus.
Definition alertAggregator.cpp:18
Definition commandReplier.cpp:21
auto format(rtctk::rtcSupervisor::RtcCommand c, FormatContext &ctx) const
Definition rtcObject.hpp:153
Basic information necessary to construct an RtcObject.
Definition rtcObject.hpp:33
std::string ps_uri
publish/subscribe uri
Definition rtcObject.hpp:43
std::string rr_uri
request/response uri
Definition rtcObject.hpp:40
std::string name
component name
Definition rtcObject.hpp:37