| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

PropertyVerifier.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_PROPERTYVERIFIER_H
2 #define GAUDIKERNEL_PROPERTYVERIFIER_H
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 // STD& STL
7 // ============================================================================
8 #include <algorithm>
9 // ============================================================================
10 // GaudiKernel
11 // ============================================================================
12 #include "GaudiKernel/PropertyTypeTraits.h"
13 // ============================================================================
14 /**********************************************************
15 * Verifier Classes are used with Property Classes to
16 * provide validation criteria for Property values.
17 *
18 **********************************************************/
24 template< class T >
25 class PropertyVerifier
26 {
27 public:
28 // Data and Function Members for Collaborators.
29 // Constructors - compiler generated default is ok
30 // Destructor
31 virtual ~PropertyVerifier() = default;
32
33 // Copy Constructor - compiler generated default is ok
34 // Assignment Operator - compiler generated default is ok
35 // Accessor members (const)
36 virtual bool isValid ( const typename Gaudi::Utils::PropertyTypeTraits<T>::CVal value ) const = 0;
37 };
38 // ============================================================================
45 template< class T >
46 class NullVerifier : public PropertyVerifier< T >
47 {
48 public:
49 // Data and Function Members for Collaborators.
50 // Constructors - compiler generated default is ok
51 // Destructor
52 ~NullVerifier() override = default;
53
54 // Copy Constructor - compiler generated default is ok
55 // Assignment Operator - compiler generated default is ok
56
57 // Accessor members (const)
58 bool isValid
59 ( const typename Gaudi::Utils::PropertyTypeTraits<T>::CVal /* val */ ) const override
60 { return true; }
61
62 };
63 // ============================================================================
67 template< class T >
68 class BoundedVerifier : public PropertyVerifier< T > { // Abstract derived class
69 public:
71 BoundedVerifier()
72 : m_hasLowerBound( false ),
73 m_hasUpperBound( false ),
74 m_lowerBound( T() ),
75 m_upperBound( T() ) { }
76
78 ~BoundedVerifier() override = default;
79
81 bool isValid( const typename Gaudi::Utils::PropertyTypeTraits<T>::CVal value ) const override
82 {
83 return
84 (( m_hasLowerBound && ( *value < m_lowerBound ) ) ? false : true ) &&
85 (( m_hasUpperBound && ( *value > m_upperBound ) ) ? false : true ) ;
86 }
87
89 bool hasLower() const { return m_hasLowerBound; }
91 bool hasUpper() const { return m_hasUpperBound; }
93 const T& lower() const { return m_lowerBound; }
95 const T& upper() const { return m_upperBound; }
96
98 void setLower( const T& value ) { m_hasLowerBound = true; m_lowerBound = value; }
100 void setUpper( const T& value ) { m_hasUpperBound = true; m_upperBound = value; }
102 void clearLower() { m_hasLowerBound = false; m_lowerBound = T(); }
104 void clearUpper() { m_hasUpperBound = false; m_upperBound = T(); }
105
107 void setBounds( const T& lower, const T& upper)
108 {
109 setLower( lower );
110 setUpper( upper );
111 }
112
114 void clearBounds()
115 {
116 clearLower();
117 clearUpper();
118 }
119
120 private:
123 bool m_hasLowerBound;
124 bool m_hasUpperBound;
125 T m_lowerBound;
126 T m_upperBound;
127 };
128 // ============================================================================
129
130 // =======================================================================
131 // The END
132 // =======================================================================
133 #endif // GAUDIKERNEL_PROPERTYVERIFIER_H
134 // =======================================================================
135
BoundedVerifier::isValid
bool isValid(const typename Gaudi::Utils::PropertyTypeTraits< T >::CVal value) const override
Check if the value is within bounds.
Definition: PropertyVerifier.h:81
PropertyVerifier
Templated Verifier base class.
Definition: PropertyVerifier.h:25
Gaudi::Utils::PropertyTypeTraits
helper structure to define the types for properties
Definition: PropertyTypeTraits.h:44
BoundedVerifier::~BoundedVerifier
~BoundedVerifier() override=default
Destructor.
NullVerifier::isValid
bool isValid(const typename Gaudi::Utils::PropertyTypeTraits< T >::CVal) const override
Definition: PropertyVerifier.h:59
PropertyVerifier::~PropertyVerifier
virtual ~PropertyVerifier()=default
BoundedVerifier::clearLower
void clearLower()
Clear lower bound value.
Definition: PropertyVerifier.h:102
PropertyVerifier::isValid
virtual bool isValid(const typename Gaudi::Utils::PropertyTypeTraits< T >::CVal value) const =0
BoundedVerifier::m_hasLowerBound
bool m_hasLowerBound
Data and Function Members for This Class Implementation.
Definition: PropertyVerifier.h:123
BoundedVerifier::setLower
void setLower(const T &value)
Set lower bound value.
Definition: PropertyVerifier.h:98
BoundedVerifier::hasLower
bool hasLower() const
Return if it has a lower bound.
Definition: PropertyVerifier.h:89
BoundedVerifier::clearUpper
void clearUpper()
Clear upper bound value.
Definition: PropertyVerifier.h:104
BoundedVerifier::setBounds
void setBounds(const T &lower, const T &upper)
Set both bounds (lower and upper) at the same time.
Definition: PropertyVerifier.h:107
BoundedVerifier
Definition: HistoProperty.h:11
NullVerifier::~NullVerifier
~NullVerifier() override=default
BoundedVerifier::lower
const T & lower() const
Return the lower bound value.
Definition: PropertyVerifier.h:93
BoundedVerifier::hasUpper
bool hasUpper() const
Return if it has a lower bound.
Definition: PropertyVerifier.h:91
dump_component_properties.value
list value
Definition: dump_component_properties.py:12
BoundedVerifier::upper
const T & upper() const
Return the upper bound value.
Definition: PropertyVerifier.h:95
PropertyTypeTraits.h
BoundedVerifier::m_lowerBound
T m_lowerBound
Definition: PropertyVerifier.h:125
BoundedVerifier::m_upperBound
T m_upperBound
Definition: PropertyVerifier.h:126
NullVerifier
Default, always true verifier.
Definition: HistoProperty.h:12
BoundedVerifier::setUpper
void setUpper(const T &value)
Set upper bound value.
Definition: PropertyVerifier.h:100
BoundedVerifier::clearBounds
void clearBounds()
Clear both bounds (lower and upper) at the same time.
Definition: PropertyVerifier.h:114
BoundedVerifier::m_hasUpperBound
bool m_hasUpperBound
Definition: PropertyVerifier.h:124
BoundedVerifier::BoundedVerifier
BoundedVerifier()
Constructors.
Definition: PropertyVerifier.h:71