FairMQ  1.3.8
C++ Message Passing Framework
DeviceRunner.h
1 /********************************************************************************
2  * Copyright (C) 2017-2018 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 namespace mq {
25 
52 {
53  public:
54  DeviceRunner(int argc, char* const argv[], bool printLogo = true);
55 
56  auto Run() -> int;
57  auto RunWithExceptionHandlers() -> int;
58 
59  template<typename H>
60  auto AddHook(std::function<void(DeviceRunner&)> hook) -> void
61  {
62  fEvents.Subscribe<H>("runner", hook);
63  }
64  template<typename H>
65  auto RemoveHook() -> void
66  {
67  fEvents.Unsubscribe<H>("runner");
68  }
69 
70  std::vector<std::string> fRawCmdLineArgs;
71  FairMQProgOptions fConfig;
72  std::unique_ptr<FairMQDevice> fDevice;
73  PluginManager fPluginManager;
74  const bool fPrintLogo;
75 
76  private:
77  EventManager fEvents;
78 };
79 
80 namespace hooks {
81 struct LoadPlugins : Event<DeviceRunner&> {};
82 struct SetCustomCmdLineOptions : Event<DeviceRunner&> {};
83 struct ModifyRawCmdLineArgs : Event<DeviceRunner&> {};
84 struct InstantiateDevice : Event<DeviceRunner&> {};
85 } /* namespace hooks */
86 
87 } /* namespace mq */
88 } /* namespace fair */
89 
90 #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:81
Manages event callbacks from different subscribers.
Definition: EventManager.h:53
manages and owns plugin instances
Definition: PluginManager.h:47
Definition: FairMQProgOptions.h:37
Definition: DeviceRunner.h:83
Definition: DeviceRunner.h:84
Definition: DeviceRunner.h:82
Tools for interfacing containers to the transport via polymorphic allocators.
Definition: DeviceRunner.h:23

privacy