RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
customCmdsImpl.hpp
Go to the documentation of this file.
1
11
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
25namespace rtctk::exampleCustom {
26
27namespace cfw = componentFramework;
28
29class CustomCmdsImpl : public rtctkexif::AsyncCustomCmds {
30public:
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 explicit CustomCmdsImpl(cfw::StateMachineEngine& engine)
38 : m_logger(cfw::GetLogger("app")), m_engine(engine) {
39 }
40
41 ::elt::mal::future<std::string> Foo() override {
42 LOG4CPLUS_TRACE(m_logger, "Received command 'Foo'");
43 return cfw::InjectReqRepEvent<events::Foo>(this->m_engine);
44 }
45
46 ::elt::mal::future<std::string> Bar(const std::string& args) override {
47 LOG4CPLUS_TRACE(m_logger, "Received command 'Bar' with payload '" + args + "'");
48 return cfw::InjectReqRepEvent<events::Bar>(this->m_engine, args);
49 }
50
51private:
52 log4cplus::Logger& m_logger;
53 cfw::StateMachineEngine& m_engine;
54};
55
56} // namespace rtctk::exampleCustom
57
58#endif
static void Register(cfw::CommandReplier &replier, cfw::StateMachineEngine &engine)
Definition customCmdsImpl.hpp:31
CustomCmdsImpl(cfw::StateMachineEngine &engine)
Definition customCmdsImpl.hpp:37
::elt::mal::future< std::string > Bar(const std::string &args) override
Definition customCmdsImpl.hpp:46
::elt::mal::future< std::string > Foo() override
Definition customCmdsImpl.hpp:41
Receive commands via MAL.
log4cplus::Logger & GetLogger(const std::string &name="app")
Get handle to a specific logger.
Definition logger.cpp:191
Logging Support Library based on log4cplus.
Provides core functionality of an RTC Component.
Definition commandReplier.cpp:21
Definition businessLogic.cpp:22
Wrapper around the SCXML State Machine Engine.