ifw-daq  3.0.0-pre2
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_
virtual elt::mal::future< std::string > Enable() override
Definition: stdCmdsImpl.hpp:79
virtual elt::mal::future< std::string > Reset() override
Definition: stdCmdsImpl.hpp:52
virtual elt::mal::future< std::string > Disable() override
Definition: stdCmdsImpl.hpp:86
virtual elt::mal::future< std::string > GetState() override
Definition: stdCmdsImpl.hpp:59
virtual elt::mal::future< std::string > GetStatus() override
Definition: stdCmdsImpl.hpp:66
virtual elt::mal::future< std::string > SetLogLevel(const std::shared_ptr< stdif::LogInfo > &info) override
Definition: stdCmdsImpl.hpp:94
virtual elt::mal::future< std::string > Exit() override
Definition: stdCmdsImpl.hpp:31
StdCmdsImpl(rad::SMAdapter &sm)
Definition: stdCmdsImpl.hpp:23
virtual ~StdCmdsImpl()
Definition: stdCmdsImpl.hpp:27
virtual elt::mal::future< std::string > Stop() override
Definition: stdCmdsImpl.hpp:45
virtual elt::mal::future< std::string > Init() override
Definition: stdCmdsImpl.hpp:38
virtual elt::mal::future< std::string > GetVersion() override
Definition: stdCmdsImpl.hpp:73
Default logger name.
log4cplus::Logger & GetLogger()
Definition: logger.cpp:14