ATLAS Offline Software
Loading...
Searching...
No Matches
ConfiguredValue.h
Go to the documentation of this file.
1/* emacs: this is -*- c++ -*- */
13
14#ifndef IDTPM2_CONFIGUREDVALUE_H
15#define IDTPM2_CONFIGUREDVALUE_H
16
17
18#include <iostream>
19
20#define GENERATOR(OP) { if ( !isset() ) return UnsetResult; return m_value OP a; }
21
22#define OPERATOR_GENERATOR(OP) template<typename U> bool operator OP ( const U& a ) const GENERATOR(OP)
23#define REV_OPERATOR_GENERATOR(OP, REVOP) template<typename T, typename U> bool operator OP ( const U& a, const ConfiguredValue<T>& p ) { return p REVOP a; }
24
25template<typename T, bool UnsetResult=false>
27
28 ConfiguredValue() : m_set(false), m_value(0) { }
29 ConfiguredValue( const T& v ) : m_set(true), m_value(v) { }
30
31 ConfiguredValue( const ConfiguredValue& c ) = default;
32
34
35 operator T&() { return m_value; }
36 operator const T&() const { return m_value; }
37
39 explicit operator bool() const { return isset(); }
40
41 bool isset() const { return m_set; }
42
43 template<typename U>
45 m_value = a;
46 m_set = true;
47 return *this;
48 }
49
56
58
59 bool m_set;
60
62
63};
64
65
72
73
74template<typename T, bool UnsetResult=false>
75std::ostream& operator<<( std::ostream& s, const ConfiguredValue<T>& p ) {
76 if (p.isset()) return s << (T)p;
77 return s << "not set";
78}
79
80#endif // IDTPM2_CONFIGUREDVALUE_H
81
82
#define OPERATOR_GENERATOR(OP)
#define REV_OPERATOR_GENERATOR(OP, REVOP)
static Double_t a
STL class.
STL namespace.
bool isset() const
ConfiguredValue & operator=(const ConfiguredValue &)=default
ConfiguredValue(const T &v)
ConfiguredValue< T > & operator=(const U &a)
ConfiguredValue(const ConfiguredValue &c)=default
#define private
Definition testRead.cxx:27