ifw  0.0.1-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
action.hpp
Go to the documentation of this file.
1 #ifndef OCM_SERVER_DAQ_TASKS_HPP
2 #define OCM_SERVER_DAQ_TASKS_HPP
3 
4 #include <typeinfo>
5 #include <functional>
6 
7 #include <rad/Logger.hpp>
8 #include <rad/ActionMgr.hpp>
9 
10 #include "daq/events.rad.hpp"
11 #include "daq/tasks.rad.hpp"
12 
13 
14 namespace daq {
15 
16 class Context;
17 
22 template<typename EVENT>
23 std::function<void(rad::AnyEvent const&)>
24 WrapAction(std::function<void(EVENT const&)> action) {
25  return [action](rad::AnyEvent const& ev) {
26  if (typeid(ev) == typeid(EVENT)) {
27  return action(reinterpret_cast<EVENT const&>(ev));
28  } else {
29  // @todo: Log something
30  RAD_LOG_ERROR() << "WrapAction called with unexpected event. Expected "
31  << typeid(EVENT).name() << " but got " << typeid(ev).name();
32  }
33  };
34 }
35 
36 class Tasks : public Action {
37 public:
38  Tasks();
39 
52  void PrepareDaq(daq::PrepareDaq const& ev) override;
53 
54  void Test(rad::AnyEvent const& ev) override{};
55 };
56 
63 //void CreateTasks(rad::ActionMgr&, DaqContext& ctx, Tasks&);
64 
65 } // namespace daq
66 #endif // #ifndef OCM_SERVER_DAQ_TASKS_HPP
#define RAD_LOG_ERROR()
Definition: Logger.hpp:266
void Test(rad::AnyEvent const &ev) override
Definition: action.hpp:54
std::function< void(rad::AnyEvent const &)> WrapAction(std::function< void(EVENT const &)> action)
Definition: action.hpp:24
void PrepareDaq(daq::PrepareDaq const &ev) override
Definition: action.cpp:9
optional int32 action
Definition: topics.proto:56
Tasks()
Definition: action.cpp:5
Definition: AnyEvent.hpp:55
optional string name
Definition: topics.proto:50