StdArrayAsProperty.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_STDARRAYASPROPERTY_H
2 #define GAUDIKERNEL_STDARRAYASPROPERTY_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 // STD & STL
7 // ============================================================================
8 #include <algorithm>
9 #include <array>
10 // ============================================================================
22 // ============================================================================
23 // 1) Streamers : value -> string
24 // ============================================================================
25 namespace Gaudi
26 {
27  // ==========================================================================
28  namespace Utils
29  {
30  // ========================================================================
31  template <class ITERATOR>
32  inline std::ostream& toStream
33  ( ITERATOR first , // begin of the sequence
34  ITERATOR last , // end of the sequence
35  std::ostream& s , // the stream
36  const std::string& open , // opening
37  const std::string& close , // closing
38  const std::string& delim ) ; // delimiter
39  // ========================================================================
48  template <class TYPE, std::size_t N>
49  inline std::ostream& toStream
50  ( const std::array<TYPE,N>& obj , std::ostream& s )
51  {
52  return toStream
53  ( obj.begin () , obj.end () , s , " ( " , " )" , " , " ) ;
54  }
55  // ========================================================================
56  } // end of namespace Gaudi::Utils
57  // ==========================================================================
58 } // end of namespace Gaudi
59 // ============================================================================
60 // 2) Parsers: string -> value
61 // ============================================================================
62 // GaudiKernel
63 // ============================================================================
64 #include "GaudiKernel/Parsers.h"
65 // ============================================================================
66 namespace Gaudi
67 {
68  // ==========================================================================
69  namespace Parsers
70  {
71  // ========================================================================
79  template <class TYPE, std::size_t N>
81  parse ( std::array<TYPE,N>& result , const std::string& input )
82  {
83  typedef std::vector<TYPE> _Vct ;
84  // create the temporaty vector
85  _Vct tmp ;
86  // parse the string
87  StatusCode sc = parse ( tmp , input ) ;
88  if ( sc.isFailure () ) { return sc ; } // RETURN
89  if ( N != tmp.size() )
90  { return StatusCode ( StatusCode::FAILURE , true ) ; } // RETURN
91  // copy vector into array
92  std::copy ( tmp.begin() , tmp.end() , result.begin() ) ;
93  //
94  return StatusCode::SUCCESS ;
95  }
96  // ========================================================================
97  } // end of namespace Gaudi::Parsers
98  // ==========================================================================
99 } // end of namespace Gaudi
100 // ============================================================================
101 // 3) Assignements and constructors
102 // ============================================================================
103 // GaudiKernel
104 // ============================================================================
106 // ============================================================================
107 namespace Gaudi
108 {
109  // ==========================================================================
110  namespace Utils
111  {
112  // ========================================================================
119  template <class T, std::size_t N>
120  struct PropertyTypeTraits<std::array<T,N> >
121  {
122  // =======================================================================
124  typedef TYPE Type ;
125  typedef const TYPE& PRef ;
126  typedef TYPE* PVal ;
127  typedef const TYPE* CVal ;
128  // =======================================================================
130  static PVal new_ ()
131  {
132  PVal tmp = new Type ;
133  std::fill_n ( tmp->begin() , N , T() ) ;
134  return tmp ;
135  }
137  static PVal new_ ( const Type& right )
138  {
139  PVal tmp = new Type ;
140  assign ( *tmp , right ) ;
141  return tmp ;
142  }
144  static void dele ( PVal right , const bool own )
145  { if ( own ) { delete right ; } }
147  static PVal copy ( PVal right , const bool own )
148  {
149  if ( !own ) { return right ; }
150  return new_ ( *right ) ;
151  }
153  static void assign ( Type& v1 , const Type& v2 )
154  { std::copy ( v2.begin() , v2.end() , v1.begin() ) ; }
156  static bool less ( const Type& v1 , const Type& v2 )
158  ( v1.begin() , v1.end () , v2.begin() , v2.end() ) ; }
159  // ======================================================================
160  } ;
161  // ========================================================================
162  } // end of namespace Gaudi::Utils
163  // ==========================================================================
164 } // end of namespace Gaudi
165 // ============================================================================
166 // The END
167 // ============================================================================
168 #endif // GAUDIKERNEL_STDARRAYASPROPERTY_H
169 // ============================================================================
helper structure to define the types for properties
T copy(T...args)
static PVal copy(PVal right, const bool own)
"smart" copy-constructor
The declaration of major parsing functions used e.g for (re)implementation of new extended properties...
static PVal new_()
some kind of default constructor
STL namespace.
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
T end(T...args)
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
STL class.
static void dele(PVal right, const bool own)
"smart" destructor
static bool less(const Type &v1, const Type &v2)
comparison (needed for bounded verifier) NON-TRIVIAL
int N
Definition: IOTest.py:90
std::ostream & toStream(ITERATOR first, ITERATOR last, std::ostream &s, const std::string &open, const std::string &close, const std::string &delim)
the helper function to print the sequence
Definition: ToStream.h:319
static void assign(Type &v1, PRef v2)
assignment
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
static PVal new_()
some kind of default constructor NON-TRIVIAL
T lexicographical_compare(T...args)
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
STL class.
T begin(T...args)
string s
Definition: gaudirun.py:245
STL class.
T fill_n(T...args)
static PVal new_(const Type &right)
some kind of copy constructor NON-TRIVIAL
STL class.
Helper functions to set/get the application return code.
Definition: __init__.py:1
static void assign(Type &v1, const Type &v2)
assignement NON-TRIVIAL