Gaudi Framework, version v24r2

Home   Generated: Wed Dec 4 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CArrayAsProperty.h
Go to the documentation of this file.
1 // $Id: $
2 // ============================================================================
3 #ifndef GAUDIKERNEL_CARRAYASPROPERTY_H
4 #define GAUDIKERNEL_CARRAYASPROPERTY_H 1
5 // ============================================================================
6 // Include files
7 // ============================================================================
8 // STD & STL
9 // ============================================================================
10 #include <algorithm>
11 // ============================================================================
12 // GauidKernel
13 // ============================================================================
16 // ============================================================================
32 // ============================================================================
33 // 1) Streamers : value -> string , done in GausiKernel/ToStream.h
34 // ============================================================================
35 // 2) Parsers : string -> value , done in GaudiKernel/Parsers.h
36 // ============================================================================
37 // 3) assigements and copy
38 // ============================================================================
39 namespace Gaudi
40 {
41  // ==========================================================================
42  namespace Utils
43  {
44  // ========================================================================
45  template <class T, unsigned int N>
46  struct PropertyTypeTraits<T(&)[N]>
47  {
48  // ======================================================================
49  typedef T(&Type) [N] ;
50  typedef T(&PRef) [N] ;
51  typedef T(*PVal) [N] ;
52  typedef const T(&CRef) [N] ;
53  typedef const T(*CVal) [N] ;
54  // ======================================================================
55  public:
56  // ======================================================================
58  static PVal new_ () { return new T[N] ; }
60  static PVal new_ ( Type right )
61  {
62  PVal tmp = new_ () ;
63  assign ( tmp , right ) ;
64  return tmp ;
65  }
67  static PVal copy ( PVal* right , const bool own )
68  {
69  if ( !own ) { return right ; }
70  return new_ ( *right ) ;
71  }
73  static void dele ( PVal right , const bool own )
74  { if ( own ) { delete[] right ; } }
75  // ======================================================================
76  // assigenements
77  static void assign ( Type v1 , PRef v2 ) { std::copy ( v2 , v2 + N , v1 ) ; }
78  static void assign ( Type v1 , CRef v2 ) { std::copy ( v2 , v2 + N , v1 ) ; }
80  static bool less ( Type v1 , Type v2 )
81  { return std::lexicographical_compare ( v1 , v1 + N , v2 , v2 + N ) ; }
82  static bool less ( Type v1 , CRef v2 )
83  { return std::lexicographical_compare ( v1 , v1 + N , v2 , v2 + N ) ; }
84  static bool less ( CRef v1 , CRef v2 )
85  { return std::lexicographical_compare ( v1 , v1 + N , v2 , v2 + N ) ; }
86  static bool less ( CRef v1 , Type v2 )
87  { return std::lexicographical_compare ( v1 , v1 + N , v2 , v2 + N ) ; }
88  // ======================================================================
89  } ;
90  // ========================================================================
92  template <class T, unsigned int N>
93  struct PropertyTypeTraits<T[N]> : public PropertyTypeTraits<T(&)[N]>
94  {} ;
95  // ========================================================================
97  template <class T, unsigned int N>
98  struct PropertyTypeTraits< const T(&)[N]>
99  {} ;
101  template <unsigned int N>
102  struct PropertyTypeTraits<char(&)[N]>
103  {} ;
104  // ========================================================================
105  } // end of namespace Gaudi::Utils
106  // ==========================================================================
107 } // end of namespace Gaudi
108 // ============================================================================
109 // property verifier
110 // ============================================================================
112 template< class T, unsigned int N>
114 {
115  // ==========================================================================
116  typedef Gaudi::Utils::PropertyTypeTraits<T[N]> Traits ;
117  // Abstract derived class
118  // ==========================================================================
119 public:
122  : m_hasLowerBound ( false )
123  , m_hasUpperBound ( false )
124  {}
126  virtual ~BoundedVerifier() { }
127 
129  bool isValid ( const typename Traits::CVal value ) const
130  {
131  return
132  ( ( m_hasLowerBound && Traits::less ( *value , m_lowerBound ) ) ? false : true )
133  &&
134  ( ( m_hasUpperBound && Traits::less ( m_upperBound , *value ) ) ? false : true ) ;
135  }
137  bool hasLower() const { return m_hasLowerBound; }
139  bool hasUpper() const { return m_hasUpperBound; }
141  typename Traits::CRef lower() const { return m_lowerBound; }
143  typename Traits::CRef upper() const { return m_upperBound; }
144 
146  void setLower( typename Traits::CRef value ) { m_hasLowerBound = true; Traits::assign ( m_lowerBound , value ) ; }
148  void setUpper( typename Traits::CRef value ) { m_hasUpperBound = true; Traits::assign ( m_upperBound , value ) ; }
150  void clearLower() { m_hasLowerBound = false; }
152  void clearUpper() { m_hasUpperBound = false; }
153 
155  void setBounds( typename Traits::CRef lower, typename Traits::CRef upper)
156  {
157  setLower( lower );
158  setUpper( upper );
159  }
160 
162  void clearBounds()
163  {
164  clearLower();
165  clearUpper();
166  }
167 
168  private:
169  // ==========================================================================
174  const T m_lowerBound [N] ;
175  const T m_upperBound [N] ;
176  // ==========================================================================
177 };
178 // ============================================================================
179 // The END
180 // ============================================================================
181 #endif // GAUDIKERNEL_CARRAYASPROPERTY_H
182 // ============================================================================

Generated at Wed Dec 4 2013 14:33:08 for Gaudi Framework, version v24r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004