ATLAS Offline Software
TPIntegerVector_p2.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TPINTEGERVECTOR_P2_H
6 #define TPINTEGERVECTOR_P2_H
7 
16 #include <vector>
17 
18 
20 
22 {
23 public:
24  typedef unsigned int value_type;
25  typedef value_type* iterator;
26  typedef const value_type* const_iterator;
27 
29 
31  : m_storage( storage ),
32  m_position( idx<<1 )
33  {}
34 
35  // --- size-related
36  unsigned size() const;
37  unsigned reserved() const;
38  void resize( size_t new_size );
39  void reserve( size_t new_size );
40  void grow( const size_t diff = 1 );
41 
42  // --- basic INT access
44  const value_type& operator[]( size_t idx ) const;
45 
46  // --- storing
47  void push_back( const value_type& val );
48  void push_int( const int& val );
49  // void push_back_short( const short& val ); // hmmm
50  void push_float( const float& val );
51  void push_double( const double& val );
52  // void push_long( const long long& val );
53 
55  void push_chars( const char * const );
57  void push_string( const std::string& );
59  void push_bytes( const void * s, size_t len );
60 
61  void push_TPObjRef( const TPObjRef& val );
62  void push_vTPObjRef( const std::vector<TPObjRef>& val );
63 
65  template<typename T>
66  static size_t size_for( const T& );
67 
68  static size_t size_for( const char * );
69  static size_t size_for_ref();
70  static size_t size_for_blob( size_t blobsize );
71 
73  size_t next_string_size( const const_iterator& iter ) const;
75  size_t next_blob_size( const const_iterator& iter ) const;
76 
77  // --- retrieving
78  // all NEXT methods advance the iterator to the next element
79  const value_type& next( const_iterator& iter ) const;
80  int next_int( const_iterator& iter ) const;
81  float next_float( const_iterator& iter ) const;
82  double next_double( const_iterator& iter ) const;
84 
85  // compatible with push_chars()
86  std::string next_string( const_iterator& iter ) const;
87  void next_chars( const_iterator& iter, char *buff, size_t bufflen ) const;
88  void next_bytes( const_iterator& iter, void *buff, size_t bufflen ) const;
89  void next_vTPObjRef( const_iterator& iter, std::vector<TPObjRef> & vect ) const;
90 
91  // --- iterators
92  iterator begin() { return &operator[](0); }
93  iterator end() { return &operator[](size()); };
94 
95  const_iterator begin() const { return &operator[](0); }
96  const_iterator end() const { return &operator[](size()); };
97 
98 protected:
99  unsigned startPos() const;
100  bool lastElement() const;
101 
102  void _store_bytes( const void *, size_t len );
103 
105  unsigned int m_position;
106 };
107 
108 
109 
110 
111 
112 // This class needs to be in the same header file, otherwise the methods of
113 // TPIntegerVector_p2 can not be inlined
114 
119 
121 {
122 public:
123 friend class TPIntegerVector_p2;
124 
126 
127  typedef unsigned position_type;
129 
130  size_t size() const {
131  return m_endPos.size() >> 1;
132  }
133 
134  void grow() {
135  position_type pos = size()? m_endPos.back() : 0;
136  m_endPos.push_back( pos );
137  m_endPos.push_back( pos );
138  }
139 
141  return TPIntegerVector_p2( this, idx );
142  }
143 
145  return TPIntegerVector_p2( this, size()-1 );
146  }
147 
148  void reserve( size_t s ) {
149  m_endPos.reserve( s<<1 );
150  }
151 
152 protected:
153  std::vector<value_type> m_data;
154  std::vector<position_type> m_endPos;
155 };
156 
157 
159 
160 
161 #endif
TPIntegerVector_p2::size_for
static size_t size_for(const T &)
tell how much space the object will take in the INT vector, so it can be reserved
get_hdefs.buff
buff
Definition: get_hdefs.py:64
TPIntegerVector_p2::m_storage
TPIntegerVectorStorage_p2 * m_storage
Definition: TPIntegerVector_p2.h:104
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
TPIntegerVectorStorage_p2::TPIntegerVectorStorage_p2
TPIntegerVectorStorage_p2()
Definition: TPIntegerVector_p2.h:125
TPIntegerVectorStorage_p2::position_type
unsigned position_type
Definition: TPIntegerVector_p2.h:127
TPIntegerVector_p2::begin
const_iterator begin() const
Definition: TPIntegerVector_p2.h:95
TPIntegerVector_p2::begin
iterator begin()
Definition: TPIntegerVector_p2.h:92
TPIntegerVector_p2::push_double
void push_double(const double &val)
TPIntegerVector_p2.icc
TPIntegerVector_p2::next_double
double next_double(const_iterator &iter) const
TPIntegerVector_p2::next_TPObjRef
TPObjRef next_TPObjRef(const_iterator &iter) const
TPIntegerVector_p2::reserve
void reserve(size_t new_size)
TPIntegerVector_p2::push_vTPObjRef
void push_vTPObjRef(const std::vector< TPObjRef > &val)
TPIntegerVector_p2::operator[]
value_type & operator[](size_t idx)
TPIntegerVector_p2::IsAnIntVect
TPIntegerVector_p2 IsAnIntVect
Definition: TPIntegerVector_p2.h:28
TPIntegerVector_p2::grow
void grow(const size_t diff=1)
TPIntegerVector_p2::size_for_ref
static size_t size_for_ref()
TPIntegerVector_p2::push_int
void push_int(const int &val)
mc.diff
diff
Definition: mc.SFGenPy8_MuMu_DD.py:14
TPIntegerVector_p2::next_float
float next_float(const_iterator &iter) const
TPIntegerVector_p2::next_string
std::string next_string(const_iterator &iter) const
TPIntegerVector_p2::operator[]
const value_type & operator[](size_t idx) const
TPIntegerVectorStorage_p2::m_endPos
std::vector< position_type > m_endPos
Definition: TPIntegerVector_p2.h:154
TPIntegerVector_p2::iterator
value_type * iterator
Definition: TPIntegerVector_p2.h:25
TPObjRef
Definition: TPObjRef.h:20
TPIntegerVector_p2::_store_bytes
void _store_bytes(const void *, size_t len)
TPIntegerVector_p2::size_for_blob
static size_t size_for_blob(size_t blobsize)
TPIntegerVector_p2::resize
void resize(size_t new_size)
TPIntegerVector_p2::end
const_iterator end() const
Definition: TPIntegerVector_p2.h:96
TPIntegerVector_p2::TPIntegerVector_p2
TPIntegerVector_p2(TPIntegerVectorStorage_p2 *storage, int idx)
Definition: TPIntegerVector_p2.h:30
TPIntegerVectorStorage_p2::operator[]
TPIntegerVector_p2 operator[](int idx)
Definition: TPIntegerVector_p2.h:140
TPIntegerVector_p2::size
unsigned size() const
TPIntegerVector_p2::push_string
void push_string(const std::string &)
store std::string (assuming 8-bit chars). Uses push_chars()
TPIntegerVectorStorage_p2::size
size_t size() const
Definition: TPIntegerVector_p2.h:130
TPIntegerVector_p2
Definition: TPIntegerVector_p2.h:22
TPIntegerVectorStorage_p2
Storage implementation for TP converters producing TP representation as series of ints.
Definition: TPIntegerVector_p2.h:121
TPIntegerVector_p2::m_position
unsigned int m_position
Definition: TPIntegerVector_p2.h:105
TPIntegerVectorStorage_p2::m_data
std::vector< value_type > m_data
Definition: TPIntegerVector_p2.h:153
TPIntegerVector_p2::next_vTPObjRef
void next_vTPObjRef(const_iterator &iter, std::vector< TPObjRef > &vect) const
TPIntegerVectorStorage_p2::value_type
TPIntegerVector_p2::value_type value_type
Definition: TPIntegerVector_p2.h:128
TPIntegerVector_p2::const_iterator
const value_type * const_iterator
Definition: TPIntegerVector_p2.h:26
TPIntegerVectorStorage_p2::TPIntegerVector_p2
friend class TPIntegerVector_p2
Definition: TPIntegerVector_p2.h:123
TPIntegerVector_p2::next_chars
void next_chars(const_iterator &iter, char *buff, size_t bufflen) const
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
TPIntegerVector_p2::next_blob_size
size_t next_blob_size(const const_iterator &iter) const
return the size of the next blob, in bytes
TPIntegerVector_p2::push_bytes
void push_bytes(const void *s, size_t len)
store blob of a given size (will write out the size)
TPIntegerVector_p2::end
iterator end()
Definition: TPIntegerVector_p2.h:93
TPIntegerVector_p2::push_back
void push_back(const value_type &val)
TPIntegerVector_p2::push_float
void push_float(const float &val)
TPIntegerVector_p2::lastElement
bool lastElement() const
TPIntegerVectorStorage_p2::back
TPIntegerVector_p2 back()
Definition: TPIntegerVector_p2.h:144
TPIntegerVector_p2::startPos
unsigned startPos() const
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
TPIntegerVectorStorage_p2::grow
void grow()
Definition: TPIntegerVector_p2.h:134
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
TPIntegerVector_p2::next_bytes
void next_bytes(const_iterator &iter, void *buff, size_t bufflen) const
TPIntegerVector_p2::push_TPObjRef
void push_TPObjRef(const TPObjRef &val)
TPIntegerVector_p2::push_chars
void push_chars(const char *const)
store zero-terminated C string (does not write out the size)
TPIntegerVectorStorage_p2::reserve
void reserve(size_t s)
Definition: TPIntegerVector_p2.h:148
TPIntegerVector_p2::value_type
unsigned int value_type
Definition: TPIntegerVector_p2.h:24
TPIntegerVector_p2::next
const value_type & next(const_iterator &iter) const
value_type
Definition: EDM_MasterSearch.h:11
TPIntegerVector_p2::next_int
int next_int(const_iterator &iter) const
TPIntegerVector_p2::reserved
unsigned reserved() const
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
TPIntegerVector_p2::size_for
static size_t size_for(const char *)
TPIntegerVector_p2::next_string_size
size_t next_string_size(const const_iterator &iter) const
return the size of the next string/chars