| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

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

- Search for |

- File List
- File Members

# PropertyVerifier.h

Go to the documentation of this file.

    00001 // $Header: /local/reps/Gaudi/GaudiKernel/GaudiKernel/PropertyVerifier.h,v 1.3 2006/06/06 16:16:23 hmd Exp $
    00002 #ifndef GAUDIKERNEL_PROPERTYVERIFIER_H
    00003 #define GAUDIKERNEL_PROPERTYVERIFIER_H
    00004 /**********************************************************
    00005  * Verifier Classes are used with Property Classes to
    00006  * provide validation criteria for Property values.
    00007  *
    00008  **********************************************************/
    00009
    00016 template< class T >
    00017 class PropertyVerifier {
    00018 public:
    00019   // Data and Function Members for Collaborators.
    00020   // Constructors - compiler generated default is ok
    00021   // Destructor
    00022   virtual ~PropertyVerifier() { }
    00023
    00024   // Copy Constructor - compiler generated default is ok
    00025   // Assignment Operator - compiler generated default is ok
    00026   // Accessor members (const)
    00027   virtual bool isValid( const T* value ) const = 0;
    00028 };
    00029
    00037 template< class T >
    00038 class BoundedVerifier : PropertyVerifier< T > {     // Abstract derived class
    00039 public:
    00041   BoundedVerifier()
    00042       : m_hasLowerBound( false ),
    00043         m_hasUpperBound( false ),
    00044         m_lowerBound( T() ),
    00045         m_upperBound( T() ) { }
    00046
    00048   virtual ~BoundedVerifier() { }
    00049
    00051   bool isValid( const T* value ) const {
    00052     return   (( m_hasLowerBound && ( *value < m_lowerBound ) ) ? false : true )
    00053           && (( m_hasUpperBound && ( *value > m_upperBound ) ) ? false : true );
    00054   }
    00055
    00057   bool        hasLower() const { return m_hasLowerBound; }
    00059   bool        hasUpper() const { return m_hasUpperBound; }
    00061   const T&    lower()    const { return m_lowerBound; }
    00063   const T&    upper()    const { return m_upperBound; }
    00064
    00066   void setLower( const T& value ) { m_hasLowerBound = true; m_lowerBound = value; }
    00068   void setUpper( const T& value ) { m_hasUpperBound = true; m_upperBound = value; }
    00070   void clearLower()  { m_hasLowerBound = false; m_lowerBound = T(); }
    00072   void clearUpper()  { m_hasUpperBound = false; m_upperBound = T(); }
    00073
    00075   void setBounds( const T& lower, const T& upper) {
    00076     setLower( lower );
    00077     setUpper( upper );
    00078   }
    00079
    00081   void clearBounds() {
    00082      clearLower();
    00083      clearUpper();
    00084   }
    00085
    00086 private:
    00089   bool  m_hasLowerBound;
    00090   bool  m_hasUpperBound;
    00091   T     m_lowerBound;
    00092   T     m_upperBound;
    00093 };
    00094
    00101 template< class T >
    00102 class NullVerifier : public PropertyVerifier< T > {
    00103 public:
    00104
    00105   // Data and Function Members for Collaborators.
    00106   // Constructors - compiler generated default is ok
    00107   // Destructor
    00108   virtual ~NullVerifier() { };
    00109
    00110   // Copy Constructor - compiler generated default is ok
    00111   // Assignment Operator - compiler generated default is ok
    00112
    00113   // Accessor members (const)
    00114   virtual bool isValid( const T* ) const { return true; }
    00115 };
    00116
    00117 #endif    // GAUDIKERNEL_PROPERTYVERIFIER_H
    00118