FairMQ  1.4.14
C++ Message Queuing Library and Framework
Control.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_PLUGINS_CONTROL
10 #define FAIR_MQ_PLUGINS_CONTROL
11 
12 #include <fairmq/Plugin.h>
13 #include <fairmq/Version.h>
14 #include <fairmq/StateQueue.h>
15 
16 #include <condition_variable>
17 #include <mutex>
18 #include <string>
19 #include <queue>
20 #include <thread>
21 #include <atomic>
22 #include <stdexcept>
23 
24 namespace fair
25 {
26 namespace mq
27 {
28 namespace plugins
29 {
30 
31 class Control : public Plugin
32 {
33  public:
34  Control(const std::string& name, const Plugin::Version version, const std::string& maintainer, const std::string& homepage, PluginServices* pluginServices);
35 
36  ~Control();
37 
38  private:
39  auto InteractiveMode() -> void;
40  static auto PrintInteractiveHelpColor() -> void;
41  static auto PrintInteractiveHelp() -> void;
42  static auto PrintStateMachineColor() -> void;
43  static auto PrintStateMachine() -> void;
44  auto StaticMode() -> void;
45  auto SignalHandler() -> void;
46  auto RunShutdownSequence() -> void;
47  auto RunStartupSequence() -> void;
48 
49  std::thread fControllerThread;
50  std::thread fSignalHandlerThread;
51  std::mutex fControllerMutex;
52  std::atomic<bool> fDeviceShutdownRequested;
53  std::atomic<bool> fDeviceHasShutdown;
54  std::atomic<bool> fPluginShutdownRequested;
55  fair::mq::StateQueue fStateQueue;
56 }; /* class Control */
57 
58 auto ControlPluginProgramOptions() -> Plugin::ProgOptions;
59 
60 REGISTER_FAIRMQ_PLUGIN(
61  Control, // Class name
62  control, // Plugin name (string, lower case chars only)
63  (Plugin::Version{FAIRMQ_VERSION_MAJOR, FAIRMQ_VERSION_MINOR, FAIRMQ_VERSION_PATCH}), // Version
64  "FairRootGroup <fairroot@gsi.de>", // Maintainer
65  "https://github.com/FairRootGroup/FairMQ", // Homepage
66  ControlPluginProgramOptions // Free function which declares custom program options for the
67  // plugin signature: () ->
68  // boost::optional<boost::program_options::options_description>
69 )
70 
71 } /* namespace plugins */
72 } /* namespace mq */
73 } /* namespace fair */
74 
75 #endif /* FAIR_MQ_PLUGINS_CONTROL */
Facilitates communication between devices and plugins.
Definition: PluginServices.h:40
Definition: Control.h:31
Definition: StateQueue.h:25
Base class for FairMQ plugins.
Definition: Plugin.h:39
Tools for interfacing containers to the transport via polymorphic allocators.
Definition: DeviceRunner.h:23
Definition: Version.h:22

privacy