ATLAS Offline Software
Loading...
Searching...
No Matches
ConfiguredValueUtils.h
Go to the documentation of this file.
1/* emacs: this is -*- c++ -*- */
12
13#ifndef TRIGIDR4MONITORING_CONFIGUREDVALUEUTILS_H
14#define TRIGIDR4MONITORING_CONFIGUREDVALUEUTILS_H
15
16#include <stdexcept>
17
18#include "Gaudi/Property.h"
19
20#include "ConfiguredValue.h"
21
22
23#define GAUDI_OPERATOR_GENERATOR(OP) template<typename T, typename U> bool operator OP ( const Gaudi::Property<ConfiguredValue<T>>& p, const U& a ) { return p.value() OP a; }
24#define REV_GAUDI_OPERATOR_GENERATOR(OP, REVOP) template<typename T, typename U> bool operator OP ( const U& a, const Gaudi::Property<ConfiguredValue<T>>& p ) { return p.value() REVOP a; }
25
26
33
34
41
42
43template<typename T, bool UnsetResult=false>
44bool isset( const Gaudi::Property<ConfiguredValue<T,UnsetResult>>& p ) { return p.value().isset(); }
45
46
47template<typename T, bool UnsetResult=false>
48StatusCode parse(ConfiguredValue<T>& p, const Gaudi::Parsers::InputData& input) {
49 T value;
50 StatusCode sc = parse(value, input);
51 if (sc.isSuccess()) p = value;
52 return sc;
53}
54
55template<typename T, bool UnsetResult = false>
56class ConfiguredValueProperty : public Gaudi::Property<ConfiguredValue<T, UnsetResult>> {
57
58 using Base = Gaudi::Property<ConfiguredValue<T, UnsetResult>>;
59
60public:
61
62 using Base::Base;
63
64 operator const T&() const { return this->value(); }
65
66 bool isset() const { return this->value().isset(); }
67
68};
69
70template<typename Exception=std::runtime_error, typename T>
71const T& require_set( const T& t ) {
72 if ( !t.isset() ) throw Exception( "no matching parameter " + t.name() );
73 return t;
74}
75
76
77template <typename... T>
78void require_set(const T&... args) { (require_set<std::runtime_error>(args), ...); }
79
80#endif // TRIGIDR4MONITORING_CONFIGUREDVALUEUTILS_H
81
82
#define REV_GAUDI_OPERATOR_GENERATOR(OP, REVOP)
#define GAUDI_OPERATOR_GENERATOR(OP)
const T & require_set(const T &t)
StatusCode parse(ConfiguredValue< T > &p, const Gaudi::Parsers::InputData &input)
bool isset(const Gaudi::Property< ConfiguredValue< T, UnsetResult > > &p)
static Double_t sc
Gaudi::Property< ConfiguredValue< T, UnsetResult > > Base
Support class for PropertyMgr.
Definition Property.h:23
=============================================================================