mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +00:00
FairMQ: Add static plugin mechanism
* Add skeleton for Take/ReleaseControl API * Add skeleton for control_static builtin plugin
This commit is contained in:
committed by
Mohammad Al-Turany
parent
17d7cd8ce4
commit
052ac8487d
11
fairmq/plugins/Builtin.h
Normal file
11
fairmq/plugins/Builtin.h
Normal file
@@ -0,0 +1,11 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
// List of all builtin plugin headers (the ones which call REGISTER_FAIRMQ_PLUGIN macro)
|
||||
|
||||
#include <fairmq/plugins/ControlStatic.h>
|
54
fairmq/plugins/ControlStatic.cxx
Normal file
54
fairmq/plugins/ControlStatic.cxx
Normal file
@@ -0,0 +1,54 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "ControlStatic.h"
|
||||
|
||||
namespace fair
|
||||
{
|
||||
namespace mq
|
||||
{
|
||||
namespace plugins
|
||||
{
|
||||
|
||||
ControlStatic::ControlStatic(
|
||||
const std::string name,
|
||||
const Plugin::Version version,
|
||||
const std::string maintainer,
|
||||
const std::string homepage,
|
||||
PluginServices* pluginServices)
|
||||
: Plugin(name, version, maintainer, homepage, pluginServices)
|
||||
{
|
||||
SubscribeToDeviceStateChange(
|
||||
[&](DeviceState newState){
|
||||
LOG(WARN) << newState;
|
||||
switch (newState)
|
||||
{
|
||||
case DeviceState::InitializingDevice:
|
||||
LOG(WARN) << GetPropertyAsString("custom-example-option");
|
||||
SetProperty("custom-example-option", std::string{"new value"});
|
||||
break;
|
||||
case DeviceState::Exiting:
|
||||
LOG(WARN) << GetProperty<std::string>("custom-example-option");
|
||||
UnsubscribeFromDeviceStateChange();
|
||||
break;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
auto ControlStaticPluginProgramOptions() -> Plugin::ProgOptions
|
||||
{
|
||||
auto plugin_options = boost::program_options::options_description{"Control Static Plugin"};
|
||||
plugin_options.add_options()
|
||||
("custom-example-option", boost::program_options::value<std::string>(), "Custom option.");
|
||||
return plugin_options;
|
||||
}
|
||||
|
||||
} /* namespace plugins */
|
||||
} /* namespace mq */
|
||||
} /* namespace fair */
|
51
fairmq/plugins/ControlStatic.h
Normal file
51
fairmq/plugins/ControlStatic.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef FAIR_MQ_PLUGINS_CONTROLSTATIC
|
||||
#define FAIR_MQ_PLUGINS_CONTROLSTATIC
|
||||
|
||||
#include <fairmq/Plugin.h>
|
||||
#include <string>
|
||||
|
||||
namespace fair
|
||||
{
|
||||
namespace mq
|
||||
{
|
||||
namespace plugins
|
||||
{
|
||||
|
||||
class ControlStatic : public Plugin
|
||||
{
|
||||
public:
|
||||
|
||||
ControlStatic(
|
||||
const std::string name,
|
||||
const Plugin::Version version,
|
||||
const std::string maintainer,
|
||||
const std::string homepage,
|
||||
PluginServices* pluginServices
|
||||
);
|
||||
}; /* class ControlStatic */
|
||||
|
||||
auto ControlStaticPluginProgramOptions() -> Plugin::ProgOptions;
|
||||
|
||||
REGISTER_FAIRMQ_PLUGIN(
|
||||
ControlStatic, // Class name
|
||||
control_static, // Plugin name (string, lower case chars only)
|
||||
(Plugin::Version{1,0,0}), // Version
|
||||
"FairRootGroup <fairroot@gsi.de>", // Maintainer
|
||||
"https://github.com/FairRootGroup/FairRoot", // Homepage
|
||||
ControlStaticPluginProgramOptions // Free function which declares custom program options for the plugin
|
||||
// signature: () -> boost::optional<boost::program_options::options_description>
|
||||
)
|
||||
|
||||
} /* namespace plugins */
|
||||
} /* namespace mq */
|
||||
} /* namespace fair */
|
||||
|
||||
#endif /* FAIR_MQ_PLUGINS_CONTROLSTATIC */
|
Reference in New Issue
Block a user