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