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