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