RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
deploymentDaemonCmdsImpl.hpp
Go to the documentation of this file.
1
11
12#ifndef RTCTK_REUSABLECOMPONENT_DEPLOYMENT_DAEMONIMPL_HPP
13#define RTCTK_REUSABLECOMPONENT_DEPLOYMENT_DAEMONIMPL_HPP
14
15#include "deploymentDaemonEvents.rad.hpp"
16#include <Rtctkif.hpp>
17
22
23#include <mal/Cii.hpp>
24
25#include <memory>
26#include <string>
27
29
30namespace cfw = rtctk::componentFramework;
31
35class DeploymentCmdsImpl : public rtctkif::AsyncDeploymentCmds {
36public:
37 static void Register(cfw::CommandReplier& replier, cfw::StateMachineEngine& engine) {
38 std::shared_ptr<elt::mal::rr::RrEntity> rr_service =
39 std::make_shared<DeploymentCmdsImpl>(engine);
40 replier.RegisterService<rtctkif::AsyncDeploymentCmds>("DeploymentCmds", rr_service);
41 }
42
43 explicit DeploymentCmdsImpl(cfw::StateMachineEngine& engine)
44 : m_logger(cfw::GetLogger("rtctk")), m_engine(engine) {
45 }
46
47 ::elt::mal::future<std::string> Deploy(const std::string& deploy_set) override {
48 LOG4CPLUS_TRACE(m_logger, "Received command 'Deploy' with deploy_set '" + deploy_set);
49 auto ev = std::make_shared<deployment_daemon_events::Deploy>(deploy_set);
50 auto f = ev->GetPayload().GetReplyFuture();
51 m_engine.PostEvent(ev);
52 return f;
53 }
54
55 ::elt::mal::future<std::string> Undeploy() override {
56 LOG4CPLUS_TRACE(m_logger, "Received command 'Undeploy'");
57 auto ev = std::make_shared<deployment_daemon_events::Undeploy>();
58 auto f = ev->GetPayload().GetReplyFuture();
59 m_engine.PostEvent(ev);
60 return f;
61 }
62
63 ::elt::mal::future<std::string> GetActiveDeployment() override {
64 LOG4CPLUS_TRACE(m_logger, "Received command 'GetActiveDeployment'");
65 return cfw::InjectReqRepEvent<deployment_daemon_events::GetActiveDeployment>(m_engine);
66 }
67
68 ::elt::mal::future<std::string> GetDescription() override {
69 LOG4CPLUS_TRACE(m_logger, "Received command 'GetDescription'");
70 return cfw::InjectReqRepEvent<deployment_daemon_events::GetDescription>(m_engine);
71 }
72
73 ::elt::mal::future<std::vector<std::string>> GetDeploymentSets() override {
74 LOG4CPLUS_TRACE(m_logger, "Received command 'GetDeploymentSets'");
75 auto ev = std::make_shared<deployment_daemon_events::GetDeploymentSets>();
76 auto f = ev->GetPayload().GetReplyFuture();
77 m_engine.PostEvent(ev);
78 return f;
79 }
80
81 ::elt::mal::future<std::vector<std::string>> GetComponents() override {
82 LOG4CPLUS_TRACE(m_logger, "Received command 'GetComponents'");
83 auto ev = std::make_shared<deployment_daemon_events::GetComponents>();
84 auto f = ev->GetPayload().GetReplyFuture();
85 m_engine.PostEvent(ev);
86 return f;
87 }
88
89 ::elt::mal::future<std::vector<std::string>> GetActiveComponents() override {
90 LOG4CPLUS_TRACE(m_logger, "Received command 'GetActiveComponents'");
91 auto ev = std::make_shared<deployment_daemon_events::GetActiveComponents>();
92 auto f = ev->GetPayload().GetReplyFuture();
93 m_engine.PostEvent(ev);
94 return f;
95 }
96
97 ::elt::mal::future<std::string> StartComponent(const std::string& component_name) override {
98 LOG4CPLUS_TRACE(m_logger,
99 "Received command 'StartComponent' with component_name'" + component_name);
100 auto ev = std::make_shared<deployment_daemon_events::StartComponent>(component_name);
101 auto f = ev->GetPayload().GetReplyFuture();
102 m_engine.PostEvent(ev);
103 return f;
104 }
105
106 ::elt::mal::future<std::string> StopComponent(const std::string& component_name) override {
107 LOG4CPLUS_TRACE(m_logger,
108 "Received command 'StopComponent' with component_name'" + component_name);
109 auto ev = std::make_shared<deployment_daemon_events::StopComponent>(component_name);
110 auto f = ev->GetPayload().GetReplyFuture();
111 m_engine.PostEvent(ev);
112 return f;
113 }
114
115 ::elt::mal::future<std::vector<std::string>> GetServices() override {
116 LOG4CPLUS_TRACE(m_logger, "Received command 'GetServices'");
117 auto ev = std::make_shared<deployment_daemon_events::GetServices>();
118 auto f = ev->GetPayload().GetReplyFuture();
119 m_engine.PostEvent(ev);
120 return f;
121 }
122
123 ::elt::mal::future<std::vector<std::string>> GetActiveServices() override {
124 LOG4CPLUS_TRACE(m_logger, "Received command 'GetActiveServices'");
125 auto ev = std::make_shared<deployment_daemon_events::GetActiveServices>();
126 auto f = ev->GetPayload().GetReplyFuture();
127 m_engine.PostEvent(ev);
128 return f;
129 }
130
131 ::elt::mal::future<std::string> GetState() override {
132 LOG4CPLUS_TRACE(m_logger, "Received command 'GetState'");
133 return cfw::InjectReqRepEvent<deployment_daemon_events::GetState>(m_engine);
134 }
135
136 ::elt::mal::future<std::string> Reset() override {
137 LOG4CPLUS_TRACE(m_logger, "Received command 'Reset'");
138 return cfw::InjectReqRepEvent<deployment_daemon_events::Reset>(m_engine);
139 }
140
141 ::elt::mal::future<std::string> Exit() override {
142 LOG4CPLUS_TRACE(m_logger, "Received command 'Exit'");
143 return cfw::InjectReqRepEvent<deployment_daemon_events::Exit>(m_engine);
144 }
145
146 ::elt::mal::future<std::string>
147 SetLogLevel(const std::shared_ptr<rtctkif::LogInfo>& info) override {
148 LOG4CPLUS_TRACE(m_logger,
149 "Received command 'SetLogLevel' with logger '" + info->getLogger() +
150 "' and level '" + info->getLevel() + "'");
151 auto ev = std::make_shared<deployment_daemon_events::SetLogLevel>(info->clone());
152 auto f = ev->GetPayload().GetReplyFuture();
153 m_engine.PostEvent(ev);
154 return f;
155 }
156
157private:
158 log4cplus::Logger& m_logger;
159 cfw::StateMachineEngine& m_engine;
160};
161
162} // namespace rtctk::deploymentDaemon
163
164#endif // RTCTK_REUSABLECOMPONENT_DEPLOYMENT_DAEMONIMPL_HPP
::elt::mal::future< std::vector< std::string > > GetServices() override
Definition deploymentDaemonCmdsImpl.hpp:115
::elt::mal::future< std::string > GetState() override
Definition deploymentDaemonCmdsImpl.hpp:131
::elt::mal::future< std::string > GetActiveDeployment() override
Definition deploymentDaemonCmdsImpl.hpp:63
::elt::mal::future< std::vector< std::string > > GetActiveServices() override
Definition deploymentDaemonCmdsImpl.hpp:123
static void Register(cfw::CommandReplier &replier, cfw::StateMachineEngine &engine)
Definition deploymentDaemonCmdsImpl.hpp:37
::elt::mal::future< std::vector< std::string > > GetComponents() override
Definition deploymentDaemonCmdsImpl.hpp:81
::elt::mal::future< std::string > Exit() override
Definition deploymentDaemonCmdsImpl.hpp:141
::elt::mal::future< std::string > StopComponent(const std::string &component_name) override
Definition deploymentDaemonCmdsImpl.hpp:106
::elt::mal::future< std::string > SetLogLevel(const std::shared_ptr< rtctkif::LogInfo > &info) override
Definition deploymentDaemonCmdsImpl.hpp:147
::elt::mal::future< std::string > Reset() override
Definition deploymentDaemonCmdsImpl.hpp:136
::elt::mal::future< std::string > Deploy(const std::string &deploy_set) override
Definition deploymentDaemonCmdsImpl.hpp:47
::elt::mal::future< std::string > Undeploy() override
Definition deploymentDaemonCmdsImpl.hpp:55
::elt::mal::future< std::vector< std::string > > GetDeploymentSets() override
Definition deploymentDaemonCmdsImpl.hpp:73
::elt::mal::future< std::string > StartComponent(const std::string &component_name) override
Definition deploymentDaemonCmdsImpl.hpp:97
::elt::mal::future< std::string > GetDescription() override
Definition deploymentDaemonCmdsImpl.hpp:68
::elt::mal::future< std::vector< std::string > > GetActiveComponents() override
Definition deploymentDaemonCmdsImpl.hpp:89
DeploymentCmdsImpl(cfw::StateMachineEngine &engine)
Definition deploymentDaemonCmdsImpl.hpp:43
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 deploymentDaemonBusinessLogic.cpp:34
Wrapper around the SCXML State Machine Engine.