FairMQ  1.4.33
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::mq::plugins
25 {
26 
27 class Control : public Plugin
28 {
29  public:
30  Control(const std::string& name, const Plugin::Version version, const std::string& maintainer, const std::string& homepage, PluginServices* pluginServices);
31 
32  ~Control();
33 
34  private:
35  auto InteractiveMode() -> void;
36  static auto PrintInteractiveHelpColor() -> void;
37  static auto PrintInteractiveHelp() -> void;
38  static auto PrintStateMachineColor() -> void;
39  static auto PrintStateMachine() -> void;
40  auto StaticMode() -> void;
41  auto SignalHandler() -> void;
42  auto RunShutdownSequence() -> void;
43  auto RunStartupSequence() -> void;
44 
45  std::thread fControllerThread;
46  std::thread fSignalHandlerThread;
47  std::mutex fControllerMutex;
48  std::atomic<bool> fDeviceShutdownRequested;
49  std::atomic<bool> fDeviceHasShutdown;
50  std::atomic<bool> fPluginShutdownRequested;
51  fair::mq::StateQueue fStateQueue;
52 }; /* class Control */
53 
54 auto ControlPluginProgramOptions() -> Plugin::ProgOptions;
55 
56 REGISTER_FAIRMQ_PLUGIN(
57  Control, // Class name
58  control, // Plugin name (string, lower case chars only)
59  (Plugin::Version{FAIRMQ_VERSION_MAJOR, FAIRMQ_VERSION_MINOR, FAIRMQ_VERSION_PATCH}), // Version
60  "FairRootGroup <fairroot@gsi.de>", // Maintainer
61  "https://github.com/FairRootGroup/FairMQ", // Homepage
62  ControlPluginProgramOptions // Free function which declares custom program options for the
63  // plugin signature: () ->
64  // boost::optional<boost::program_options::options_description>
65 )
66 
67 } // namespace fair::mq::plugins
68 
69 #endif /* FAIR_MQ_PLUGINS_CONTROL */
fair::mq::tools::Version
Definition: Version.h:25
fair::mq::plugins::Control
Definition: Control.h:34
fair::mq::StateQueue
Definition: StateQueue.h:30

privacy