ATLAS Offline Software
Loading...
Searching...
No Matches
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
14
15
16#include <vector>
17
18
20
22{
23public:
24 typedef unsigned int value_type;
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
43 value_type& operator[]( size_t idx );
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
98protected:
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{
122public:
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
152protected:
153 std::vector<value_type> m_data;
154 std::vector<position_type> m_endPos;
155};
156
157
159
160
161#endif
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Definition Jet.cxx:631
Storage implementation for TP converters producing TP representation as series of ints.
TPIntegerVector_p2::value_type value_type
TPIntegerVector_p2 operator[](int idx)
std::vector< value_type > m_data
std::vector< position_type > m_endPos
size_t next_blob_size(const const_iterator &iter) const
return the size of the next blob, in bytes
static size_t size_for_blob(size_t blobsize)
const value_type & next(const_iterator &iter) const
const value_type & operator[](size_t idx) const
TPIntegerVector_p2(TPIntegerVectorStorage_p2 *storage, int idx)
bool lastElement() const
TPObjRef next_TPObjRef(const_iterator &iter) const
std::string next_string(const_iterator &iter) const
void push_bytes(const void *s, size_t len)
store blob of a given size (will write out the size)
void next_bytes(const_iterator &iter, void *buff, size_t bufflen) const
TPIntegerVector_p2 IsAnIntVect
void push_float(const float &val)
const_iterator end() const
static size_t size_for(const T &)
tell how much space the object will take in the INT vector, so it can be reserved
int next_int(const_iterator &iter) const
void push_back(const value_type &val)
void push_TPObjRef(const TPObjRef &val)
value_type & operator[](size_t idx)
void next_vTPObjRef(const_iterator &iter, std::vector< TPObjRef > &vect) const
void push_int(const int &val)
unsigned size() const
static size_t size_for_ref()
void push_string(const std::string &)
store std::string (assuming 8-bit chars). Uses push_chars()
void push_double(const double &val)
void next_chars(const_iterator &iter, char *buff, size_t bufflen) const
const_iterator begin() const
TPIntegerVectorStorage_p2 * m_storage
size_t next_string_size(const const_iterator &iter) const
return the size of the next string/chars
void reserve(size_t new_size)
const value_type * const_iterator
unsigned reserved() const
static size_t size_for(const char *)
void push_vTPObjRef(const std::vector< TPObjRef > &val)
void _store_bytes(const void *, size_t len)
void grow(const size_t diff=1)
double next_double(const_iterator &iter) const
float next_float(const_iterator &iter) const
unsigned startPos() const
void resize(size_t new_size)
void push_chars(const char *const)
store zero-terminated C string (does not write out the size)
This class is an object reference used in Athena persistent data model.
Definition TPObjRef.h:20