ifw-daq  2.1.0-pre1
IFW Data Acquisition modules
stdCmdsImpl.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup server
4  * @copyright ESO - European Southern Observatory
5  * @author
6  *
7  * @brief StdCmds Interface implementation header file.
8  */
9 #ifndef SERVER_STD_CMDS_IMPL_HPP_
10 #define SERVER_STD_CMDS_IMPL_HPP_
11 
12 #include "events.rad.hpp"
13 #include "logger.hpp"
14 
15 #include <Stdif.hpp>
16 #include <rad/exceptions.hpp>
17 #include <rad/smAdapter.hpp>
18 
19 namespace server {
20 
21 class StdCmdsImpl : public stdif::AsyncStdCmds {
22 public:
23  explicit StdCmdsImpl(rad::SMAdapter& sm) : m_sm(sm) {
24  RAD_TRACE(GetLogger());
25  }
26 
27  virtual ~StdCmdsImpl() {
28  RAD_TRACE(GetLogger());
29  }
30 
31  virtual elt::mal::future<std::string> Exit() override {
32  RAD_TRACE(GetLogger());
33  auto ev = std::make_shared<Events::Exit>();
34  m_sm.PostEvent(ev);
35  return ev->GetPayload().GetReplyFuture();
36  }
37 
38  virtual elt::mal::future<std::string> Init() override {
39  RAD_TRACE(GetLogger());
40  auto ev = std::make_shared<Events::Init>();
41  m_sm.PostEvent(ev);
42  return ev->GetPayload().GetReplyFuture();
43  }
44 
45  virtual elt::mal::future<std::string> Stop() override {
46  RAD_TRACE(GetLogger());
47  auto ev = std::make_shared<Events::Stop>();
48  m_sm.PostEvent(ev);
49  return ev->GetPayload().GetReplyFuture();
50  }
51 
52  virtual elt::mal::future<std::string> Reset() override {
53  RAD_TRACE(GetLogger());
54  auto ev = std::make_shared<Events::Reset>();
55  m_sm.PostEvent(ev);
56  return ev->GetPayload().GetReplyFuture();
57  }
58 
59  virtual elt::mal::future<std::string> GetState() override {
60  RAD_TRACE(GetLogger());
61  auto ev = std::make_shared<Events::GetState>();
62  m_sm.PostEvent(ev);
63  return ev->GetPayload().GetReplyFuture();
64  }
65 
66  virtual elt::mal::future<std::string> GetStatus() override {
67  RAD_TRACE(GetLogger());
68  auto ev = std::make_shared<Events::GetStatus>();
69  m_sm.PostEvent(ev);
70  return ev->GetPayload().GetReplyFuture();
71  }
72 
73  virtual elt::mal::future<std::string> GetVersion() override {
74 
75  RAD_TRACE(GetLogger());
76  return boost::make_ready_future(std::string(VERSION));
77  }
78 
79  virtual elt::mal::future<std::string> Enable() override {
80  RAD_TRACE(GetLogger());
81  auto ev = std::make_shared<Events::Enable>();
82  m_sm.PostEvent(ev);
83  return ev->GetPayload().GetReplyFuture();
84  }
85 
86  virtual elt::mal::future<std::string> Disable() override {
87  RAD_TRACE(GetLogger());
88  auto ev = std::make_shared<Events::Disable>();
89  m_sm.PostEvent(ev);
90  return ev->GetPayload().GetReplyFuture();
91  }
92 
93  virtual elt::mal::future<std::string>
94  SetLogLevel(const std::shared_ptr<stdif::LogInfo>& info) override {
95  RAD_TRACE(GetLogger());
96  auto ev = std::make_shared<Events::SetLogLevel>(info->clone());
97  m_sm.PostEvent(ev);
98  return ev->GetPayload().GetReplyFuture();
99  }
100 
101 private:
102  rad::SMAdapter& m_sm;
103 };
104 
105 } // namespace server
106 
107 #endif // SERVER_STD_CMDS_IMPL_HPP_
server::StdCmdsImpl::Reset
virtual elt::mal::future< std::string > Reset() override
Definition: stdCmdsImpl.hpp:52
server::StdCmdsImpl::StdCmdsImpl
StdCmdsImpl(rad::SMAdapter &sm)
Definition: stdCmdsImpl.hpp:23
server::StdCmdsImpl::Init
virtual elt::mal::future< std::string > Init() override
Definition: stdCmdsImpl.hpp:38
server::StdCmdsImpl::~StdCmdsImpl
virtual ~StdCmdsImpl()
Definition: stdCmdsImpl.hpp:27
server::StdCmdsImpl::GetVersion
virtual elt::mal::future< std::string > GetVersion() override
Definition: stdCmdsImpl.hpp:73
server::StdCmdsImpl
Definition: stdCmdsImpl.hpp:21
server::StdCmdsImpl::GetState
virtual elt::mal::future< std::string > GetState() override
Definition: stdCmdsImpl.hpp:59
server
Definition: actionMgr.cpp:21
server::StdCmdsImpl::Enable
virtual elt::mal::future< std::string > Enable() override
Definition: stdCmdsImpl.hpp:79
server::GetLogger
log4cplus::Logger & GetLogger()
Definition: logger.cpp:14
logger.hpp
Default logger name.
server::StdCmdsImpl::Stop
virtual elt::mal::future< std::string > Stop() override
Definition: stdCmdsImpl.hpp:45
server::StdCmdsImpl::Exit
virtual elt::mal::future< std::string > Exit() override
Definition: stdCmdsImpl.hpp:31
server::StdCmdsImpl::GetStatus
virtual elt::mal::future< std::string > GetStatus() override
Definition: stdCmdsImpl.hpp:66
server::StdCmdsImpl::SetLogLevel
virtual elt::mal::future< std::string > SetLogLevel(const std::shared_ptr< stdif::LogInfo > &info) override
Definition: stdCmdsImpl.hpp:94
server::StdCmdsImpl::Disable
virtual elt::mal::future< std::string > Disable() override
Definition: stdCmdsImpl.hpp:86