RTC Toolkit  2.0.0
rtcCmdsImpl.hpp
Go to the documentation of this file.
1 
12 #ifndef RTCTK_COMPONENTFRAMEWORK_RTCCMDSIMPL_HPP
13 #define RTCTK_COMPONENTFRAMEWORK_RTCCMDSIMPL_HPP
14 
15 #include <Rtctkif.hpp>
17 #include <rtctk/componentFramework/events.rad.hpp>
21 
22 #include <mal/Cii.hpp>
23 
24 #include <memory>
25 #include <string>
26 
27 namespace rtctk::componentFramework {
28 
32 class FuncCmdsImpl : public rtctkif::AsyncFuncCmds {
33 public:
34  static void Register(CommandReplier& replier, StateMachineEngine& engine) {
35  std::shared_ptr<elt::mal::rr::RrEntity> rr_service = std::make_shared<FuncCmdsImpl>(engine);
36  replier.RegisterService<rtctkif::AsyncFuncCmds>("FuncCmds", rr_service);
37  }
38 
39  FuncCmdsImpl(StateMachineEngine& engine) : m_engine(engine) {
40  }
41 
42  ::elt::mal::future<std::string> Recover() override {
43  LOG4CPLUS_TRACE(GetLogger(), "Received command 'Recover'");
44  return InjectReqRepEvent<events::Recover>(m_engine);
45  }
46 
47  ::elt::mal::future<std::string> Run() override {
48  LOG4CPLUS_TRACE(GetLogger(), "Received command 'Run'");
49  return InjectReqRepEvent<events::Run>(m_engine);
50  }
51 
52  ::elt::mal::future<std::string> Idle() override {
53  LOG4CPLUS_TRACE(GetLogger(), "Received command 'Idle'");
54  return InjectReqRepEvent<events::Idle>(m_engine);
55  }
56 
57 private:
58  StateMachineEngine& m_engine;
59 };
60 
64 class UpdateCmdsImpl : public rtctkif::AsyncUpdateCmds {
65 public:
66  static void Register(CommandReplier& replier, StateMachineEngine& engine) {
67  std::shared_ptr<elt::mal::rr::RrEntity> rr_service =
68  std::make_shared<UpdateCmdsImpl>(engine);
69  replier.RegisterService<rtctkif::AsyncUpdateCmds>("UpdateCmds", rr_service);
70  }
71 
72  UpdateCmdsImpl(StateMachineEngine& engine) : m_engine(engine) {
73  }
74 
75  ::elt::mal::future<std::string> Update(std::string const& args) override {
76  LOG4CPLUS_TRACE(GetLogger(), "Received command 'Update' with payload '" + args + "'");
77  return InjectReqRepEvent<events::Update>(m_engine, args);
78  }
79 
80 private:
81  StateMachineEngine& m_engine;
82 };
83 
84 } // namespace rtctk::componentFramework
85 
86 #endif
commandReplier.hpp
Receive commands via MAL.
stateMachineEngine.hpp
Wrapper around the SCXML State Machine Engine.
rtctk::componentFramework
Definition: commandReplier.cpp:20
rtctk::componentFramework::StateMachineEngine
Definition: stateMachineEngine.hpp:31
rtctk::componentFramework::FuncCmdsImpl::Idle
::elt::mal::future< std::string > Idle() override
Definition: rtcCmdsImpl.hpp:52
rtctk::componentFramework::GetLogger
log4cplus::Logger & GetLogger(const std::string &name="")
Get handle to a specific logger (used with logging macros)
rtctk::componentFramework::FuncCmdsImpl::Register
static void Register(CommandReplier &replier, StateMachineEngine &engine)
Definition: rtcCmdsImpl.hpp:34
rtctk::componentFramework::FuncCmdsImpl::Run
::elt::mal::future< std::string > Run() override
Definition: rtcCmdsImpl.hpp:47
rtctk::componentFramework::CommandReplier
Class that handles reception of commands using MAL.
Definition: commandReplier.hpp:26
rtctk::componentFramework::UpdateCmdsImpl::UpdateCmdsImpl
UpdateCmdsImpl(StateMachineEngine &engine)
Definition: rtcCmdsImpl.hpp:72
rtctk::componentFramework::FuncCmdsImpl::FuncCmdsImpl
FuncCmdsImpl(StateMachineEngine &engine)
Definition: rtcCmdsImpl.hpp:39
logger.hpp
Logging Support Library based on log4cplus.
rtctk::componentFramework::CommandReplier::RegisterService
void RegisterService(std::string const &name, std::shared_ptr< elt::mal::rr::RrEntity > &service)
Definition: commandReplier.hpp:33
rtctk::componentFramework::FuncCmdsImpl
Class that handles reception of commands Run, Idle and Recover using MAL.
Definition: rtcCmdsImpl.hpp:32
malEventInjector.hpp
Provides core functionality of an RTC Component.
rtctk::componentFramework::UpdateCmdsImpl::Register
static void Register(CommandReplier &replier, StateMachineEngine &engine)
Definition: rtcCmdsImpl.hpp:66
rtctk::componentFramework::UpdateCmdsImpl::Update
::elt::mal::future< std::string > Update(std::string const &args) override
Definition: rtcCmdsImpl.hpp:75
rtctk::componentFramework::UpdateCmdsImpl
Class that handles reception of command Update using MAL.
Definition: rtcCmdsImpl.hpp:64
rtctk::componentFramework::FuncCmdsImpl::Recover
::elt::mal::future< std::string > Recover() override
Definition: rtcCmdsImpl.hpp:42