-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExamplePlugin.h.in
More file actions
69 lines (60 loc) · 2.84 KB
/
ExamplePlugin.h.in
File metadata and controls
69 lines (60 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/********************************************************************************
* 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 EXAMPLE_PLUGIN
#define EXAMPLE_PLUGIN
#include <fairmq/Plugin.h>
namespace example
{
class ExamplePlugin : public fair::mq::Plugin
{
public:
ExamplePlugin(
const std::string name,
const fair::mq::Plugin::Version version,
const std::string maintainer,
const std::string homepage,
fair::mq::PluginServices* pluginServices)
: fair::mq::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;
}
}
);
}
}; /* class ExamplePlugin */
auto ExamplePluginProgramOptions() -> fair::mq::Plugin::ProgOptions
{
auto plugin_options = boost::program_options::options_description{"Example Plugin"};
plugin_options.add_options()
("custom-example-option", boost::program_options::value<std::string>(), "Custom option.")
("custom-example-option2", boost::program_options::value<std::string>(), "Another custom option.");
return plugin_options;
}
REGISTER_FAIRMQ_PLUGIN(
ExamplePlugin, // Class name
example, // Plugin name (string, lower case chars only)
(fair::mq::Plugin::Version{@VERSION_MAJOR@,@VERSION_MINOR@,@VERSION_PATCH@}), // Version
"Mr. Example <example@test.net>", // Maintainer
"https://github.com/FairRootGroup/FairMQPlugin_example", // Homepage
example::ExamplePluginProgramOptions // Free function which declares custom program options for the plugin
// signature: () -> boost::optional<boost::program_options::options_description>
)
} /* namespace example */
#endif /* EXAMPLE_PLUGIN */