RTC Toolkit  1.0.0
stdCmdsImpl.hpp
Go to the documentation of this file.
1 
12 #ifndef RTCTK_COMPONENTFRAMEWORK_STDCMDSIMPL_HPP
13 #define RTCTK_COMPONENTFRAMEWORK_STDCMDSIMPL_HPP
14 
15 #include <Svif.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 StdCmdsImpl : public stdif::AsyncStdCmds {
33 public:
34  static void Register(CommandReplier& replier, StateMachineEngine& engine) {
35  std::shared_ptr<elt::mal::rr::RrEntity> rr_service = std::make_shared<StdCmdsImpl>(engine);
36  replier.RegisterService<stdif::AsyncStdCmds>("StdCmds", rr_service);
37  }
38 
39  StdCmdsImpl(StateMachineEngine& engine) : m_engine(engine) {
40  }
41 
42  ::elt::mal::future<std::string> Init() override {
43  LOG4CPLUS_TRACE(GetLogger(), "Received command 'Init'");
44  return InjectReqRepEvent<events::Init>(m_engine);
45  }
46 
47  ::elt::mal::future<std::string> Stop() override {
48  LOG4CPLUS_TRACE(GetLogger(), "Received command 'Stop'");
49  return InjectReqRepEvent<events::Stop>(m_engine);
50  }
51 
52  ::elt::mal::future<std::string> Reset() override {
53  LOG4CPLUS_TRACE(GetLogger(), "Received command 'Reset'");
54  return InjectReqRepEvent<events::Reset>(m_engine);
55  }
56 
57  ::elt::mal::future<std::string> Enable() override {
58  LOG4CPLUS_TRACE(GetLogger(), "Received command 'Enable'");
59  return InjectReqRepEvent<events::Enable>(m_engine);
60  }
61 
62  ::elt::mal::future<std::string> Disable() override {
63  LOG4CPLUS_TRACE(GetLogger(), "Received command 'Disable'");
64  return InjectReqRepEvent<events::Disable>(m_engine);
65  }
66 
67  ::elt::mal::future<std::string> GetState() override {
68  LOG4CPLUS_TRACE(GetLogger(), "Received command 'GetState'");
69  return InjectReqRepEvent<events::GetState>(m_engine);
70  }
71 
72  ::elt::mal::future<std::string> GetVersion() override {
73  LOG4CPLUS_TRACE(GetLogger(), "Received command 'GetVersion'");
74  return InjectReqRepEvent<events::GetVersion>(m_engine);
75  }
76 
77  ::elt::mal::future<std::string> Exit() override {
78  LOG4CPLUS_TRACE(GetLogger(), "Received command 'Exit'");
79  return InjectReqRepEvent<events::Exit>(m_engine);
80  }
81 
82  ::elt::mal::future<std::string> SetLogLevel(const std::string& level) override {
83  LOG4CPLUS_TRACE(GetLogger(), "Received command 'SetLogLevel' with payload '" + level + "'");
84  return InjectReqRepEvent<events::SetLogLevel>(m_engine, level);
85  }
86 
87 private:
88  StateMachineEngine& m_engine;
89 };
90 
91 } // namespace rtctk::componentFramework
92 
93 #endif // RTCTK_COMPONENTFRAMEWORK_STDCMDSIMPL_HPP
rtctk::componentFramework::StdCmdsImpl::GetState
::elt::mal::future< std::string > GetState() override
Definition: stdCmdsImpl.hpp:67
commandReplier.hpp
Receive commands via MAL.
rtctk::componentFramework::StdCmdsImpl::StdCmdsImpl
StdCmdsImpl(StateMachineEngine &engine)
Definition: stdCmdsImpl.hpp:39
rtctk::componentFramework::StdCmdsImpl::Exit
::elt::mal::future< std::string > Exit() override
Definition: stdCmdsImpl.hpp:77
stateMachineEngine.hpp
Wrapper around the SCXML State Machine Engine.
rtctk::componentFramework
Definition: commandReplier.cpp:20
rtctk::componentFramework::StdCmdsImpl::Reset
::elt::mal::future< std::string > Reset() override
Definition: stdCmdsImpl.hpp:52
rtctk::componentFramework::StateMachineEngine
Definition: stateMachineEngine.hpp:31
rtctk::componentFramework::GetLogger
log4cplus::Logger & GetLogger(const std::string &name="")
Get handle to a specific logger (used with logging macros)
rtctk::componentFramework::CommandReplier
Class that handles reception of commands using MAL.
Definition: commandReplier.hpp:26
rtctk::componentFramework::StdCmdsImpl::Stop
::elt::mal::future< std::string > Stop() override
Definition: stdCmdsImpl.hpp:47
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::StdCmdsImpl::Disable
::elt::mal::future< std::string > Disable() override
Definition: stdCmdsImpl.hpp:62
rtctk::componentFramework::StdCmdsImpl::SetLogLevel
::elt::mal::future< std::string > SetLogLevel(const std::string &level) override
Definition: stdCmdsImpl.hpp:82
rtctk::componentFramework::StdCmdsImpl::GetVersion
::elt::mal::future< std::string > GetVersion() override
Definition: stdCmdsImpl.hpp:72
malEventInjector.hpp
Provides core functionality of an RTC Component.
rtctk::componentFramework::StdCmdsImpl::Init
::elt::mal::future< std::string > Init() override
Definition: stdCmdsImpl.hpp:42
rtctk::componentFramework::StdCmdsImpl
Class that handles reception of stdif commands.
Definition: stdCmdsImpl.hpp:32
rtctk::componentFramework::StdCmdsImpl::Enable
::elt::mal::future< std::string > Enable() override
Definition: stdCmdsImpl.hpp:57
rtctk::componentFramework::StdCmdsImpl::Register
static void Register(CommandReplier &replier, StateMachineEngine &engine)
Definition: stdCmdsImpl.hpp:34