ifw-ocf  2.0.0-dev
 All Classes Namespaces Files Functions Variables Groups
action.hpp
Go to the documentation of this file.
1 
8 #ifndef OCM_SERVER_DAQ_TASKS_HPP
9 #define OCM_SERVER_DAQ_TASKS_HPP
10 
11 #include <typeinfo>
12 #include <functional>
13 
14 #include <rad/logger.hpp>
15 #include <rad/actionMgr.hpp>
16 
17 #include "daq/events.rad.hpp"
18 #include "daq/tasks.rad.hpp"
19 
20 
21 namespace daq {
22 
23 class Context;
24 
29 template<typename EVENT>
30 std::function<void(rad::AnyEvent const&)>
31 WrapAction(std::function<void(EVENT const&)> action) {
32  return [action](rad::AnyEvent const& ev) {
33  if (typeid(ev) == typeid(EVENT)) {
34  return action(reinterpret_cast<EVENT const&>(ev));
35  } else {
36  // @todo: Log something
37  RAD_LOG_ERROR() << "WrapAction called with unexpected event. Expected "
38  << typeid(EVENT).name() << " but got " << typeid(ev).name();
39  }
40  };
41 }
42 
43 class Tasks : public Action {
44 public:
45  Tasks();
46 
59  void PrepareDaq(daq::PrepareDaq const& ev) override;
60 
61  void Test(rad::AnyEvent const& ev) override{};
62 };
63 
70 //void CreateTasks(rad::ActionMgr&, DaqContext& ctx, Tasks&);
71 
72 } // namespace daq
73 #endif // #ifndef OCM_SERVER_DAQ_TASKS_HPP
std::function< void(rad::AnyEvent const &)> WrapAction(std::function< void(EVENT const &)> action)
Definition: action.hpp:31
void Test(rad::AnyEvent const &ev) override
Definition: action.hpp:61
void PrepareDaq(daq::PrepareDaq const &ev) override
Definition: action.cpp:16
Tasks()
Definition: action.cpp:12
Definition: action.hpp:43