| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 // ============================================================================
14 #include "GaudiKernel/PropertyTypeTraits.h"
15 // ============================================================================
16 /**********************************************************
17 * Verifier Classes are used with Property Classes to
18 * provide validation criteria for Property values.
19 *
20 **********************************************************/
26 template< class T >
27 class PropertyVerifier
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:
73 BoundedVerifier()
74 : m_hasLowerBound( false ),
75 m_hasUpperBound( false ),
76 m_lowerBound( T() ),
77 m_upperBound( T() ) { }
78
80 virtual ~BoundedVerifier() { }
81
83 bool isValid( const typename Gaudi::Utils::PropertyTypeTraits<T>::CVal value ) const
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:
125 bool m_hasLowerBound;
126 bool m_hasUpperBound;
127 T m_lowerBound;
128 T m_upperBound;
129 };
130 // ============================================================================
131
132 // =======================================================================
133 // The END
134 // =======================================================================
135 #endif // GAUDIKERNEL_PROPERTYVERIFIER_H
136 // =======================================================================
137