All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
BoostArrayAsProperty.h
Go to the documentation of this file.
1 // $Id: $
2 // ============================================================================
3 #ifndef GAUDIKERNEL_BOOSTARRAYASPROPERTY_H
4 #define GAUDIKERNEL_BOOSTARRAYASPROPERTY_H 1
5 // ============================================================================
6 // Include files
7 // ============================================================================
8 // STD & STL
9 // ============================================================================
10 #include <algorithm>
11 // ============================================================================
12 // Boost
13 // ============================================================================
14 #include "boost/array.hpp"
15 // ============================================================================
25 // ============================================================================
26 // 1) Streamers : value -> string
27 // ============================================================================
28 namespace Gaudi
29 {
30  // ==========================================================================
31  namespace Utils
32  {
33  // ========================================================================
34  template <class ITERATOR>
35  inline std::ostream& toStream
36  ( ITERATOR first , // begin of the sequence
37  ITERATOR last , // end of the sequence
38  std::ostream& s , // the stream
39  const std::string& open , // opening
40  const std::string& close , // closing
41  const std::string& delim ) ; // delimiter
42  // ========================================================================
51  template <class TYPE, std::size_t N>
52  inline std::ostream& toStream
53  ( const boost::array<TYPE,N>& obj , std::ostream& s )
54  {
55  return toStream
56  ( obj.begin () , obj.end () , s , "( " , " )" , " , " ) ;
57  }
58  // ========================================================================
59  } // end of namespace Gaudi::Utils
60  // ==========================================================================
61 } // end of namespace Gaudi
62 // ============================================================================
63 // 2) Parsers: string -> value
64 // ============================================================================
65 // GaudiKernel
66 // ============================================================================
67 #include "GaudiKernel/Parsers.h"
68 // ============================================================================
69 namespace Gaudi
70 {
71  // ==========================================================================
72  namespace Parsers
73  {
74  // ========================================================================
82  template <class TYPE, std::size_t N>
83  StatusCode
84  parse ( boost::array<TYPE,N>& result , const std::string& input )
85  {
86  typedef std::vector<TYPE> _Vct ;
87  // create the temporaty vector
88  _Vct tmp ;
89  // parse the string
90  StatusCode sc = parse ( tmp , input ) ;
91  if ( sc.isFailure () ) { return sc ; } // RETURN
92  if ( N != tmp.size() )
93  { return StatusCode ( StatusCode::FAILURE , true ) ; } // RETURN
94  // copy vector into array
95  std::copy ( tmp.begin() , tmp.end() , result.begin() ) ;
96  //
97  return StatusCode::SUCCESS ;
98  }
99  // ========================================================================
100  } // end of namespace Gaudi::Parsers
101  // ==========================================================================
102 } // end of namespace Gaudi
103 // ============================================================================
104 // 3) Assignements and constructors
105 // ============================================================================
106 // GaudiKernel
107 // ============================================================================
109 // ============================================================================
110 namespace Gaudi
111 {
112  // ==========================================================================
113  namespace Utils
114  {
115  // ========================================================================
122  template <class T, std::size_t N>
123  struct PropertyTypeTraits<boost::array<T,N> >
124  {
125  // =======================================================================
126  typedef boost::array<T,N> TYPE ;
127  typedef TYPE Type ;
128  typedef const TYPE& PRef ;
129  typedef TYPE* PVal ;
130  typedef const TYPE* CVal ;
131  // =======================================================================
133  static PVal new_ ()
134  {
135  PVal tmp = new Type ;
136  std::fill_n ( tmp->begin() , N , T() ) ;
137  return tmp ;
138  }
140  static PVal new_ ( const Type& right )
141  {
142  PVal tmp = new Type ;
143  assign ( *tmp , right ) ;
144  return tmp ;
145  }
147  static void dele ( PVal right , const bool own )
148  { if ( own ) { delete right ; } }
150  static PVal copy ( PVal right , const bool own )
151  {
152  if ( !own ) { return right ; }
153  return new_ ( *right ) ;
154  }
156  static void assign ( Type& v1 , const Type& v2 )
157  { std::copy ( v2.begin() , v2.end() , v1.begin() ) ; }
159  static bool less ( const Type& v1 , const Type& v2 )
160  { return std::lexicographical_compare
161  ( v1.begin() , v1.end () , v2.begin() , v2.end() ) ; }
162  // ======================================================================
163  } ;
164  // ========================================================================
165  } // end of namespace Gaudi::Utils
166  // ==========================================================================
167 } // end of namespace Gaudi
168 // ============================================================================
169 // The END
170 // ============================================================================
171 #endif // GAUDIKERNEL_BOOSTARRAYASPROPERTY_H
172 // ============================================================================
helper structure to define the types for properties
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:72
static PVal copy(PVal right, const bool own)
"smart" copy-constructor
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:341
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:30
static void dele(PVal right, const bool own)
"smart" destructor
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
static PVal new_()
some kind of default constructor NON-TRIVIAL
string s
Definition: gaudirun.py:210
This is a number of static methods for bootstrapping the Gaudi framework.
Definition: Bootstrap.h:15