| The Gaudi Framework v27r1

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

- File List
- File Members

CArrayAsProperty.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_CARRAYASPROPERTY_H
2 #define GAUDIKERNEL_CARRAYASPROPERTY_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 // STD & STL
7 // ============================================================================
8 #include <algorithm>
9 // ============================================================================
10 // GauidKernel
11 // ============================================================================
12 #include "GaudiKernel/PropertyTypeTraits.h"
13 #include "GaudiKernel/PropertyVerifier.h"
14 // ============================================================================
29 // ============================================================================
30 // 1) Streamers : value -> string , done in GausiKernel/ToStream.h
31 // ============================================================================
32 // 2) Parsers : string -> value , done in GaudiKernel/Parsers.h
33 // ============================================================================
34 // 3) assignments and copy
35 // ============================================================================
36 namespace Gaudi
37 {
38 // ==========================================================================
39 namespace Utils
40 {
41 // ========================================================================
42 template <class T, unsigned int N>
43 struct PropertyTypeTraits<T(&)[N]>
44 {
45 // ======================================================================
46 typedef T(&Type) [N] ;
47 typedef T(&PRef) [N] ;
48 typedef T(*PVal) [N] ;
49 typedef const T(&CRef) [N] ;
50 typedef const T(*CVal) [N] ;
51 // ======================================================================
52 public:
53 // ======================================================================
55 static PVal new_ () { return new T[N] ; }
57 static PVal new_ ( Type right )
58 {
59 PVal tmp = new_ () ;
60 assign ( tmp , right ) ;
61 return tmp ;
62 }
64 static PVal copy ( PVal* right , const bool own )
65 {
66 if ( !own ) { return right ; }
67 return new_ ( *right ) ;
68 }
70 static void dele ( PVal right , const bool own )
71 { if ( own ) { delete[] right ; } }
72 // ======================================================================
73 // assigenements
74 static void assign ( Type v1 , PRef v2 ) { std::copy ( v2 , v2 + N , v1 ) ; }
75 static void assign ( Type v1 , CRef v2 ) { std::copy ( v2 , v2 + N , v1 ) ; }
77 static bool less ( Type v1 , Type v2 )
78 { return std::lexicographical_compare ( v1 , v1 + N , v2 , v2 + N ) ; }
79 static bool less ( Type v1 , CRef v2 )
80 { return std::lexicographical_compare ( v1 , v1 + N , v2 , v2 + N ) ; }
81 static bool less ( CRef v1 , CRef v2 )
82 { return std::lexicographical_compare ( v1 , v1 + N , v2 , v2 + N ) ; }
83 static bool less ( CRef v1 , Type v2 )
84 { return std::lexicographical_compare ( v1 , v1 + N , v2 , v2 + N ) ; }
85 // ======================================================================
86 } ;
87 // ========================================================================
89 template <class T, unsigned int N>
90 struct PropertyTypeTraits<T[N]> : public PropertyTypeTraits<T(&)[N]>
91 {} ;
92 // ========================================================================
94 template <class T, unsigned int N>
95 struct PropertyTypeTraits< const T(&)[N]>
96 {} ;
98 template <unsigned int N>
99 struct PropertyTypeTraits<char(&)[N]>
100 {} ;
101 // ========================================================================
102 } // end of namespace Gaudi::Utils
103 // ==========================================================================
104 } // end of namespace Gaudi
105 // ============================================================================
106 // property verifier
107 // ============================================================================
109 template< class T, unsigned int N>
110 class BoundedVerifier<T[N]> : PropertyVerifier<T[N]>
111 {
112 // ==========================================================================
113 typedef Gaudi::Utils::PropertyTypeTraits<T[N]> Traits ;
114 // Abstract derived class
115 // ==========================================================================
116 public:
118 BoundedVerifier()
119 : m_hasLowerBound ( false )
120 , m_hasUpperBound ( false )
121 {}
123 virtual ~BoundedVerifier() = default;
124
126 bool isValid ( const typename Traits::CVal value ) const
127 {
128 return
129 ( ( m_hasLowerBound && Traits::less ( *value , m_lowerBound ) ) ? false : true )
130 &&
131 ( ( m_hasUpperBound && Traits::less ( m_upperBound , *value ) ) ? false : true ) ;
132 }
134 bool hasLower() const { return m_hasLowerBound; }
136 bool hasUpper() const { return m_hasUpperBound; }
138 typename Traits::CRef lower() const { return m_lowerBound; }
140 typename Traits::CRef upper() const { return m_upperBound; }
141
143 void setLower( typename Traits::CRef value ) { m_hasLowerBound = true; Traits::assign ( m_lowerBound , value ) ; }
145 void setUpper( typename Traits::CRef value ) { m_hasUpperBound = true; Traits::assign ( m_upperBound , value ) ; }
147 void clearLower() { m_hasLowerBound = false; }
149 void clearUpper() { m_hasUpperBound = false; }
150
152 void setBounds( typename Traits::CRef lower, typename Traits::CRef upper)
153 {
154 setLower( lower );
155 setUpper( upper );
156 }
157
159 void clearBounds()
160 {
161 clearLower();
162 clearUpper();
163 }
164
165 private:
166 // ==========================================================================
169 bool m_hasLowerBound ;
170 bool m_hasUpperBound ;
171 const T m_lowerBound [N] ;
172 const T m_upperBound [N] ;
173 // ==========================================================================
174 };
175 // ============================================================================
176 // The END
177 // ============================================================================
178 #endif // GAUDIKERNEL_CARRAYASPROPERTY_H
179 // ============================================================================
Gaudi::Utils::PropertyTypeTraits< T(&)[N]>::dele
static void dele(PVal right, const bool own)
"smart" pseudo-destructor
Definition: CArrayAsProperty.h:70
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.
Gaudi::Utils::PropertyTypeTraits< T(&)[N]>::less
static bool less(Type v1, CRef v2)
Definition: CArrayAsProperty.h:79
std::copy
T copy(T...args)
BoundedVerifier< T[N]>::m_hasLowerBound
bool m_hasLowerBound
Data and Function Members for This Class Implementation.
Definition: CArrayAsProperty.h:169
BoundedVerifier< T[N]>::clearBounds
void clearBounds()
Clear both bounds (lower and upper) at the same time.
Definition: CArrayAsProperty.h:159
Gaudi::Utils::PropertyTypeTraits< T(&)[N]>::less
static bool less(Type v1, Type v2)
comparison (needed for bounded verifier)
Definition: CArrayAsProperty.h:77
BoundedVerifier< T[N]>::clearUpper
void clearUpper()
Clear upper bound value.
Definition: CArrayAsProperty.h:149
BoundedVerifier< T[N]>::clearLower
void clearLower()
Clear lower bound value.
Definition: CArrayAsProperty.h:147
BoundedVerifier::clearLower
void clearLower()
Clear lower bound value.
Definition: PropertyVerifier.h:102
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::clearUpper
void clearUpper()
Clear upper bound value.
Definition: PropertyVerifier.h:104
BoundedVerifier
Definition: HistoProperty.h:11
BoundedVerifier< T[N]>::upper
Traits::CRef upper() const
Return the upper bound value.
Definition: CArrayAsProperty.h:140
BoundedVerifier< T[N]>::setBounds
void setBounds(typename Traits::CRef lower, typename Traits::CRef upper)
Set both bounds (lower and upper) at the same time.
Definition: CArrayAsProperty.h:152
PropertyVerifier.h
Gaudi::Utils::PropertyTypeTraits< T(&)[N]>::new_
static PVal new_(Type right)
some kind of "copy" constructor
Definition: CArrayAsProperty.h:57
IOTest.N
int N
Definition: IOTest.py:90
BoundedVerifier::lower
const T & lower() const
Return the lower bound value.
Definition: PropertyVerifier.h:93
Gaudi::Utils::PropertyTypeTraits< T(&)[N]>::assign
static void assign(Type v1, CRef v2)
Definition: CArrayAsProperty.h:75
Gaudi::Utils::PropertyTypeTraits< T(&)[N]>::assign
static void assign(Type v1, PRef v2)
Definition: CArrayAsProperty.h:74
BoundedVerifier< T[N]>::setLower
void setLower(typename Traits::CRef value)
Set lower bound value.
Definition: CArrayAsProperty.h:143
dump_component_properties.value
list value
Definition: dump_component_properties.py:12
Gaudi::Utils::PropertyTypeTraits< T(&)[N]>::new_
static PVal new_()
some kind of "default" constructor
Definition: CArrayAsProperty.h:55
BoundedVerifier< T[N]>::isValid
bool isValid(const typename Traits::CVal value) const
Check if the value is within bounds.
Definition: CArrayAsProperty.h:126
Gaudi::Utils::PropertyTypeTraits< T(&)[N]>::less
static bool less(CRef v1, CRef v2)
Definition: CArrayAsProperty.h:81
std::lexicographical_compare
T lexicographical_compare(T...args)
BoundedVerifier::upper
const T & upper() const
Return the upper bound value.
Definition: PropertyVerifier.h:95
PropertyTypeTraits.h
Gaudi::Utils::PropertyTypeTraits< T(&)[N]>::copy
static PVal copy(PVal *right, const bool own)
some kind of "smart"-pseudo-constructor
Definition: CArrayAsProperty.h:64
BoundedVerifier::m_lowerBound
T m_lowerBound
Definition: PropertyVerifier.h:125
BoundedVerifier::m_upperBound
T m_upperBound
Definition: PropertyVerifier.h:126
BoundedVerifier< T[N]>::hasLower
bool hasLower() const
Return if it has a lower bound.
Definition: CArrayAsProperty.h:134
BoundedVerifier::setUpper
void setUpper(const T &value)
Set upper bound value.
Definition: PropertyVerifier.h:100
BoundedVerifier< T[N]>::hasUpper
bool hasUpper() const
Return if it has a lower bound.
Definition: CArrayAsProperty.h:136
BoundedVerifier< T[N]>::Traits
Gaudi::Utils::PropertyTypeTraits< T[N]> Traits
Definition: CArrayAsProperty.h:113
Tuples::Type
Type
the list of available types for ntuples
Definition: TupleObj.h:79
BoundedVerifier< T[N]>::setUpper
void setUpper(typename Traits::CRef value)
Set upper bound value.
Definition: CArrayAsProperty.h:145
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
BoundedVerifier::m_hasUpperBound
bool m_hasUpperBound
Definition: PropertyVerifier.h:124
BoundedVerifier< T[N]>::m_hasUpperBound
bool m_hasUpperBound
Definition: CArrayAsProperty.h:170
BoundedVerifier< T[N]>::lower
Traits::CRef lower() const
Return the lower bound value.
Definition: CArrayAsProperty.h:138
BoundedVerifier< T[N]>::BoundedVerifier
BoundedVerifier()
Constructors.
Definition: CArrayAsProperty.h:118
Gaudi::Utils::PropertyTypeTraits< T(&)[N]>::less
static bool less(CRef v1, Type v2)
Definition: CArrayAsProperty.h:83