RTC Toolkit  1.0.0
customCmdsImpl.hpp
Go to the documentation of this file.
1 
12 #ifndef RTCTK_EXAMPLECUSTOM_CUSTOMCMDSIMPL_HPP
13 #define RTCTK_EXAMPLECUSTOM_CUSTOMCMDSIMPL_HPP
14 
15 #include "Rtctkexif.hpp"
16 #include "customEvents.rad.hpp"
21 #include <mal/Cii.hpp>
22 #include <memory>
23 #include <string>
24 
25 namespace rtctk::exampleCustom {
26 
27 namespace cfw = componentFramework;
28 
29 class CustomCmdsImpl : public rtctkexif::AsyncCustomCmds {
30 public:
31  static void Register(cfw::CommandReplier& replier, cfw::StateMachineEngine& engine) {
32  std::shared_ptr<elt::mal::rr::RrEntity> rr_service =
33  std::make_shared<CustomCmdsImpl>(engine);
34  replier.RegisterService<rtctkexif::AsyncCustomCmds>("CustomCmds", rr_service);
35  }
36 
37  CustomCmdsImpl(cfw::StateMachineEngine& engine) : m_engine(engine) {
38  }
39 
40  ::elt::mal::future<std::string> Foo() override {
41  LOG4CPLUS_TRACE(cfw::GetLogger(), "Received command 'Foo'");
42  return cfw::InjectReqRepEvent<events::Foo>(this->m_engine);
43  }
44 
45  ::elt::mal::future<std::string> Bar(std::string const& args) override {
46  LOG4CPLUS_TRACE(cfw::GetLogger(), "Received command 'Bar' with payload '" + args + "'");
47  return cfw::InjectReqRepEvent<events::Bar>(this->m_engine, args);
48  }
49 
50 private:
51  cfw::StateMachineEngine& m_engine;
52 };
53 
54 } // namespace rtctk::exampleCustom
55 
56 #endif
commandReplier.hpp
Receive commands via MAL.
rtctk::exampleCustom::CustomCmdsImpl::Register
static void Register(cfw::CommandReplier &replier, cfw::StateMachineEngine &engine)
Definition: customCmdsImpl.hpp:31
stateMachineEngine.hpp
Wrapper around the SCXML State Machine Engine.
rtctk::componentFramework::StateMachineEngine
Definition: stateMachineEngine.hpp:31
rtctk::exampleCustom::CustomCmdsImpl::Bar
::elt::mal::future< std::string > Bar(std::string const &args) override
Definition: customCmdsImpl.hpp:45
rtctk::componentFramework::GetLogger
log4cplus::Logger & GetLogger(const std::string &name="")
Get handle to a specific logger (used with logging macros)
rtctk::exampleCustom::CustomCmdsImpl::Foo
::elt::mal::future< std::string > Foo() override
Definition: customCmdsImpl.hpp:40
rtctk::componentFramework::CommandReplier
Class that handles reception of commands using MAL.
Definition: commandReplier.hpp:26
rtctk::exampleCustom
Definition: businessLogic.cpp:22
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
malEventInjector.hpp
Provides core functionality of an RTC Component.
rtctk::exampleCustom::CustomCmdsImpl
Definition: customCmdsImpl.hpp:29
rtctk::exampleCustom::CustomCmdsImpl::CustomCmdsImpl
CustomCmdsImpl(cfw::StateMachineEngine &engine)
Definition: customCmdsImpl.hpp:37