FairMQ  1.2.3
C++ Message Passing Framework
DeviceRunner.h
1 /********************************************************************************
2  * Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #ifndef FAIR_MQ_DEVICERUNNER_H
10 #define FAIR_MQ_DEVICERUNNER_H
11 
12 #include <fairmq/EventManager.h>
13 #include <fairmq/PluginManager.h>
14 #include <FairMQDevice.h>
15 #include <FairMQLogger.h>
16 #include <options/FairMQProgOptions.h>
17 
18 #include <functional>
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 namespace fair
24 {
25 namespace mq
26 {
27 
52 {
53  public:
54  DeviceRunner(int argc, char* const argv[]);
55 
56  auto Run() -> int;
57  auto RunWithExceptionHandlers() -> int;
58 
59  template<typename H>
60  auto AddHook(std::function<void(DeviceRunner&)> hook) -> void { fEvents.Subscribe<H>("runner", hook); }
61  template<typename H>
62  auto RemoveHook() -> void { fEvents.Unsubscribe<H>("runner"); }
63 
64  std::vector<std::string> fRawCmdLineArgs;
65  std::shared_ptr<PluginManager> fPluginManager;
66  FairMQProgOptions fConfig;
67  std::shared_ptr<FairMQDevice> fDevice;
68 
69  private:
70  EventManager fEvents;
71 };
72 
73 namespace hooks
74 {
75 struct LoadPlugins : Event<DeviceRunner&> {};
76 struct SetCustomCmdLineOptions : Event<DeviceRunner&> {};
77 struct ModifyRawCmdLineArgs : Event<DeviceRunner&> {};
78 struct InstantiateDevice : Event<DeviceRunner&> {};
79 } /* namespace hooks */
80 
81 } /* namespace mq */
82 } /* namespace fair */
83 
84 #endif /* FAIR_MQ_DEVICERUNNER_H */
Utility class to facilitate a convenient top-level device launch/shutdown.
Definition: DeviceRunner.h:51
Definition: EventManager.h:33
Definition: DeviceRunner.h:75
Manages event callbacks from different subscribers.
Definition: EventManager.h:53
Definition: FairMQProgOptions.h:41
Definition: DeviceRunner.h:77
Definition: DeviceRunner.h:78
Definition: DeviceRunner.h:76
Definition: DeviceRunner.h:23