-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathConfigParamSpec.h
More file actions
71 lines (61 loc) · 2.41 KB
/
ConfigParamSpec.h
File metadata and controls
71 lines (61 loc) · 2.41 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
70
71
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#ifndef FRAMEWORK_CONFIGPARAMSPEC_H
#define FRAMEWORK_CONFIGPARAMSPEC_H
#include "Framework/Variant.h"
#include "Framework/ConfigurableKinds.h"
#include <string>
namespace o2::framework
{
/// @class ConfigParamSpec Definition of options for a processor
/// An option definition consists of a name, a type, a help message, and
/// an optional default value. The type of the argument has to be specified
/// in terms of VariantType
///
/// Options and arguments can be retrieved from the init context in the
/// initialization function:
/// context.options().get<TYPE>("NAME")
///
/// All options are also forwarded to the device.
struct ConfigParamSpec {
using ParamType = VariantType;
struct HelpString {
const char* c_str() const { return str.c_str(); }
std::string str;
};
template <typename T>
ConfigParamSpec(std::string, ParamType, Variant, T)
: type(VariantType::Unknown), kind{ConfigParamKind::kGeneric}
{
static_assert(std::is_same<T, HelpString>::value,
R"(help string must be brace-enclosed, e.g. '{"help"}')");
}
ConfigParamSpec(std::string _name, ParamType _type,
Variant _defaultValue, HelpString _help, ConfigParamKind kind_ = ConfigParamKind::kGeneric)
: name(_name), type(_type), defaultValue(_defaultValue), help(_help), kind{kind_}
{
}
/// config spec without default value, explicitely marked as 'empty'
/// and will be ignored at other places
ConfigParamSpec(std::string _name, ParamType _type, HelpString _help)
: name(_name), type(_type), defaultValue(VariantType::Empty), help(_help), kind{ConfigParamKind::kGeneric} {}
bool operator==(ConfigParamSpec const& that) const
{
return name == that.name && type == that.type;
}
std::string name;
ParamType type;
Variant defaultValue;
HelpString help;
ConfigParamKind kind;
};
} // namespace o2::framework
#endif // FRAMEWORK_CONFIGPARAMSPEC_H