Source · fairmq/plugins/control/
Control.hheader
Described in Plugins and control, Device states, Threads in a device, Stop a topology without losing messages, Test your devices, Command-line options, States and transitions, Your first device.
1/********************************************************************************2 * Copyright (C) 2017-2022 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_CONTROL10#define FAIR_MQ_PLUGINS_CONTROL11 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 24namespace fair::mq::plugins25{26 27class Control : public Plugin28{29 public:30 Control(const std::string& name, Plugin::Version version, const std::string& maintainer, const std::string& homepage, PluginServices* pluginServices);31 Control(const Control&) = delete;32 Control(Control&&) = delete;33 Control& operator=(const Control&) = delete;34 Control& operator=(Control&&) = delete;35 36 ~Control() override;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 PrintNumberOfConnectedPeers() -> void;45 auto StaticMode() -> void;46 auto GUIMode() -> void;47 auto SignalHandler() -> void;48 auto RunShutdownSequence() -> void;49 auto RunREPL() -> void;50 auto RunStartupSequence() -> void;51 52 std::thread fControllerThread;53 std::thread fSignalHandlerThread;54 std::mutex fControllerMutex;55 std::atomic<bool> fDeviceShutdownRequested;56 std::atomic<bool> fDeviceHasShutdown;57 std::atomic<bool> fPluginShutdownRequested;58 fair::mq::StateQueue fStateQueue;59}; /* class Control */60 61auto ControlPluginProgramOptions() -> Plugin::ProgOptions;62 63REGISTER_FAIRMQ_PLUGIN(64 Control, // Class name65 control, // Plugin name (string, lower case chars only)66 (Plugin::Version{FAIRMQ_VERSION_MAJOR, FAIRMQ_VERSION_MINOR, FAIRMQ_VERSION_PATCH}), // Version67 "FairRootGroup <fairroot@gsi.de>", // Maintainer68 "https://github.com/FairRootGroup/FairMQ", // Homepage69 ControlPluginProgramOptions // Free function which declares custom program options for the70 // plugin signature: () ->71 // boost::optional<boost::program_options::options_description>72)73 74} // namespace fair::mq::plugins75 76#endif /* FAIR_MQ_PLUGINS_CONTROL */