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