BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
eformat::PagedMemory< TMAXPAGES >::const_iterator Class Reference

#include <PagedMemory.h>

Public Member Functions

 const_iterator ()
 const_iterator (const const_iterator &other)
 ~const_iterator ()
const_iterator & operator= (const const_iterator &other)
bool operator!= (const const_iterator &other) const
bool operator== (const const_iterator &other) const
uint32_t operator[] (size_t pos) const
uint32_t at (size_t pos) const
uint32_t operator* (void) const
const_iterator & operator++ (void)
const_iterator & operator-- ()
const_iterator & operator+= (size_t offset)
const_iterator & operator-= (size_t offset)
bool operator< (const const_iterator &other) const
bool operator> (const const_iterator &other) const
int32_t operator- (const const_iterator &other) const
 const_iterator ()
 const_iterator (const const_iterator &other)
 ~const_iterator ()
const_iterator & operator= (const const_iterator &other)
bool operator!= (const const_iterator &other) const
bool operator== (const const_iterator &other) const
uint32_t operator[] (size_t pos) const
uint32_t at (size_t pos) const
uint32_t operator* (void) const
const_iterator & operator++ (void)
const_iterator & operator-- ()
const_iterator & operator+= (size_t offset)
const_iterator & operator-= (size_t offset)
bool operator< (const const_iterator &other) const
bool operator> (const const_iterator &other) const
int32_t operator- (const const_iterator &other) const
 const_iterator ()
 const_iterator (const const_iterator &other)
 ~const_iterator ()
const_iterator & operator= (const const_iterator &other)
bool operator!= (const const_iterator &other) const
bool operator== (const const_iterator &other) const
uint32_t operator[] (size_t pos) const
uint32_t at (size_t pos) const
uint32_t operator* (void) const
const_iterator & operator++ (void)
const_iterator & operator-- ()
const_iterator & operator+= (size_t offset)
const_iterator & operator-= (size_t offset)
bool operator< (const const_iterator &other) const
bool operator> (const const_iterator &other) const
int32_t operator- (const const_iterator &other) const

Friends

class PagedMemory

Detailed Description

template<unsigned int TMAXPAGES = 128>
class eformat::PagedMemory< TMAXPAGES >::const_iterator

Defines an iterator-like type for this type of memory. There are no guarantees on the iteration. The user should test and only iterate from begin() till end()

Definition at line 97 of file Event/eformat/include/eformat/PagedMemory.h.

Constructor & Destructor Documentation

◆ const_iterator() [1/6]

template<unsigned int TMAXPAGES = 128>
eformat::PagedMemory< TMAXPAGES >::const_iterator::const_iterator ( )
inline

Returns an iterator that points nowhere, to fake similar behaviour as the normal pointers.

Definition at line 117 of file Event/eformat/include/eformat/PagedMemory.h.

117: m_node(), m_off() {}

◆ const_iterator() [2/6]

template<unsigned int TMAXPAGES = 128>
eformat::PagedMemory< TMAXPAGES >::const_iterator::const_iterator ( const const_iterator & other)
inline

Copies the value of an iterator

Parameters
otherThe iterator to copy the data from

Definition at line 124 of file Event/eformat/include/eformat/PagedMemory.h.

125 : m_node( other.m_node ), m_off( other.m_off ) {}

◆ ~const_iterator() [1/3]

template<unsigned int TMAXPAGES = 128>
eformat::PagedMemory< TMAXPAGES >::const_iterator::~const_iterator ( )
inline

Destroys an iterator

Definition at line 130 of file Event/eformat/include/eformat/PagedMemory.h.

130{}

◆ const_iterator() [3/6]

template<unsigned int TMAXPAGES = 128>
eformat::PagedMemory< TMAXPAGES >::const_iterator::const_iterator ( )
inline

Returns an iterator that points nowhere, to fake similar behaviour as the normal pointers.

Definition at line 117 of file InstallArea/x86_64-el9-gcc13-dbg/include/eformat/PagedMemory.h.

117: m_node(), m_off() {}

◆ const_iterator() [4/6]

template<unsigned int TMAXPAGES = 128>
eformat::PagedMemory< TMAXPAGES >::const_iterator::const_iterator ( const const_iterator & other)
inline

Copies the value of an iterator

Parameters
otherThe iterator to copy the data from

Definition at line 124 of file InstallArea/x86_64-el9-gcc13-dbg/include/eformat/PagedMemory.h.

125 : m_node( other.m_node ), m_off( other.m_off ) {}

◆ ~const_iterator() [2/3]

template<unsigned int TMAXPAGES = 128>
eformat::PagedMemory< TMAXPAGES >::const_iterator::~const_iterator ( )
inline

Destroys an iterator

Definition at line 130 of file InstallArea/x86_64-el9-gcc13-dbg/include/eformat/PagedMemory.h.

130{}

◆ const_iterator() [5/6]

template<unsigned int TMAXPAGES = 128>
eformat::PagedMemory< TMAXPAGES >::const_iterator::const_iterator ( )
inline

Returns an iterator that points nowhere, to fake similar behaviour as the normal pointers.

Definition at line 117 of file InstallArea/x86_64-el9-gcc13-opt/include/eformat/PagedMemory.h.

117: m_node(), m_off() {}

◆ const_iterator() [6/6]

template<unsigned int TMAXPAGES = 128>
eformat::PagedMemory< TMAXPAGES >::const_iterator::const_iterator ( const const_iterator & other)
inline

Copies the value of an iterator

Parameters
otherThe iterator to copy the data from

Definition at line 124 of file InstallArea/x86_64-el9-gcc13-opt/include/eformat/PagedMemory.h.

125 : m_node( other.m_node ), m_off( other.m_off ) {}

◆ ~const_iterator() [3/3]

template<unsigned int TMAXPAGES = 128>
eformat::PagedMemory< TMAXPAGES >::const_iterator::~const_iterator ( )
inline

Destroys an iterator

Definition at line 130 of file InstallArea/x86_64-el9-gcc13-opt/include/eformat/PagedMemory.h.

130{}

Member Function Documentation

◆ at() [1/3]

template<unsigned int TMAXPAGES>
uint32_t eformat::PagedMemory< TMAXPAGES >::const_iterator::at ( size_t pos) const

Gets a value away N positions from this iterator, checked and may throw an exception

Parameters
posThe number "N" of positions away from this iterator

Definition at line 320 of file Event/eformat/include/eformat/PagedMemory.h.

320 {
321 // immediate return (most of the cases)
322 if ( m_off + pos < m_node->end )
323 { // trying to reach data on the current page
324 return CAST32( m_node->page->iov_base )[( m_off + pos ) - m_node->start];
325 }
326
327 // immediate points of failure
328 if ( !m_node || ( m_node->next == 0 && ( m_off + pos ) >= m_node->end ) )
329 throw EFORMAT_OUT_OF_BOUNDS( 0, pos << 2 );
330
331 // if I get here, the data is on another page and the request might still be
332 // out of bounds, so watch.
333 const_iterator it = *this;
334 it += pos;
335 return it.at( 0 );
336}
#define EFORMAT_OUT_OF_BOUNDS(size, pos)

Referenced by at().

◆ at() [2/3]

template<unsigned int TMAXPAGES = 128>
uint32_t eformat::PagedMemory< TMAXPAGES >::const_iterator::at ( size_t pos) const

Gets a value away N positions from this iterator, checked and may throw an exception

Parameters
posThe number "N" of positions away from this iterator

◆ at() [3/3]

template<unsigned int TMAXPAGES = 128>
uint32_t eformat::PagedMemory< TMAXPAGES >::const_iterator::at ( size_t pos) const

Gets a value away N positions from this iterator, checked and may throw an exception

Parameters
posThe number "N" of positions away from this iterator

◆ operator!=() [1/3]

template<unsigned int TMAXPAGES = 128>
bool eformat::PagedMemory< TMAXPAGES >::const_iterator::operator!= ( const const_iterator & other) const

Compares two pointers

Parameters
otherThe other iterator to compare this one with.

◆ operator!=() [2/3]

template<unsigned int TMAXPAGES = 128>
bool eformat::PagedMemory< TMAXPAGES >::const_iterator::operator!= ( const const_iterator & other) const

Compares two pointers

Parameters
otherThe other iterator to compare this one with.

◆ operator!=() [3/3]

template<unsigned int TMAXPAGES = 128>
bool eformat::PagedMemory< TMAXPAGES >::const_iterator::operator!= ( const const_iterator & other) const

Compares two pointers

Parameters
otherThe other iterator to compare this one with.

◆ operator*() [1/3]

template<unsigned int TMAXPAGES = 128>
uint32_t eformat::PagedMemory< TMAXPAGES >::const_iterator::operator* ( void ) const
inline

Gets the current value for the pointed position, as a 32-bit integer. This is unchecked so you have to make sure you are before end().

Definition at line 175 of file Event/eformat/include/eformat/PagedMemory.h.

175 {
176 return CAST32( m_node->page->iov_base )[m_off - m_node->start];
177 }

◆ operator*() [2/3]

template<unsigned int TMAXPAGES = 128>
uint32_t eformat::PagedMemory< TMAXPAGES >::const_iterator::operator* ( void ) const
inline

Gets the current value for the pointed position, as a 32-bit integer. This is unchecked so you have to make sure you are before end().

Definition at line 175 of file InstallArea/x86_64-el9-gcc13-dbg/include/eformat/PagedMemory.h.

175 {
176 return CAST32( m_node->page->iov_base )[m_off - m_node->start];
177 }

◆ operator*() [3/3]

template<unsigned int TMAXPAGES = 128>
uint32_t eformat::PagedMemory< TMAXPAGES >::const_iterator::operator* ( void ) const
inline

Gets the current value for the pointed position, as a 32-bit integer. This is unchecked so you have to make sure you are before end().

Definition at line 175 of file InstallArea/x86_64-el9-gcc13-opt/include/eformat/PagedMemory.h.

175 {
176 return CAST32( m_node->page->iov_base )[m_off - m_node->start];
177 }

◆ operator++() [1/3]

template<unsigned int TMAXPAGES>
eformat::PagedMemory< TMAXPAGES >::const_iterator & eformat::PagedMemory< TMAXPAGES >::const_iterator::operator++ ( void )

Advances forward on the pointing place, 4 bytes or 1 word. This is the prefix operator.

Definition at line 340 of file Event/eformat/include/eformat/PagedMemory.h.

340 {
341 ++m_off;
342 if ( m_off >= ( m_node->end ) )
343 {
344 if ( !m_node->next )
345 { // it was the last
346 m_off = m_node->end;
347 return *this;
348 }
349 m_node = m_node->next;
350 m_off = m_node->start;
351 }
352 return *this;
353}

◆ operator++() [2/3]

template<unsigned int TMAXPAGES = 128>
const_iterator & eformat::PagedMemory< TMAXPAGES >::const_iterator::operator++ ( void )

Advances forward on the pointing place, 4 bytes or 1 word. This is the prefix operator.

◆ operator++() [3/3]

template<unsigned int TMAXPAGES = 128>
const_iterator & eformat::PagedMemory< TMAXPAGES >::const_iterator::operator++ ( void )

Advances forward on the pointing place, 4 bytes or 1 word. This is the prefix operator.

◆ operator+=() [1/3]

template<unsigned int TMAXPAGES>
eformat::PagedMemory< TMAXPAGES >::const_iterator & eformat::PagedMemory< TMAXPAGES >::const_iterator::operator+= ( size_t offset)

Advances forward on the pointing place, by a number of (32-bit) words

Parameters
offsetThe amount of words to advance

Definition at line 374 of file Event/eformat/include/eformat/PagedMemory.h.

374 {
375 size_t aim = offset + m_off;
376 while ( aim >= ( m_node->end ) )
377 {
378 if ( m_node->next ) m_node = m_node->next;
379 else
380 { // it was the last
381 m_off = m_node->end;
382 return *this;
383 }
384 }
385 m_off = aim;
386 return *this;
387}

◆ operator+=() [2/3]

template<unsigned int TMAXPAGES = 128>
const_iterator & eformat::PagedMemory< TMAXPAGES >::const_iterator::operator+= ( size_t offset)

Advances forward on the pointing place, by a number of (32-bit) words

Parameters
offsetThe amount of words to advance

◆ operator+=() [3/3]

template<unsigned int TMAXPAGES = 128>
const_iterator & eformat::PagedMemory< TMAXPAGES >::const_iterator::operator+= ( size_t offset)

Advances forward on the pointing place, by a number of (32-bit) words

Parameters
offsetThe amount of words to advance

◆ operator-() [1/3]

template<unsigned int TMAXPAGES = 128>
int32_t eformat::PagedMemory< TMAXPAGES >::const_iterator::operator- ( const const_iterator & other) const
inline

Returns the difference in position between two iterators

Parameters
otherThe other iterator to compare to

Definition at line 228 of file Event/eformat/include/eformat/PagedMemory.h.

228 {
229 return (int32_t)m_off - (int32_t)other.m_off;
230 }

◆ operator-() [2/3]

template<unsigned int TMAXPAGES = 128>
int32_t eformat::PagedMemory< TMAXPAGES >::const_iterator::operator- ( const const_iterator & other) const
inline

Returns the difference in position between two iterators

Parameters
otherThe other iterator to compare to

Definition at line 228 of file InstallArea/x86_64-el9-gcc13-dbg/include/eformat/PagedMemory.h.

228 {
229 return (int32_t)m_off - (int32_t)other.m_off;
230 }

◆ operator-() [3/3]

template<unsigned int TMAXPAGES = 128>
int32_t eformat::PagedMemory< TMAXPAGES >::const_iterator::operator- ( const const_iterator & other) const
inline

Returns the difference in position between two iterators

Parameters
otherThe other iterator to compare to

Definition at line 228 of file InstallArea/x86_64-el9-gcc13-opt/include/eformat/PagedMemory.h.

228 {
229 return (int32_t)m_off - (int32_t)other.m_off;
230 }

◆ operator--() [1/3]

template<unsigned int TMAXPAGES>
eformat::PagedMemory< TMAXPAGES >::const_iterator & eformat::PagedMemory< TMAXPAGES >::const_iterator::operator-- ( void )

Step back on the pointing place, 4 bytes or 1 word. This is the prefix operator.

Definition at line 357 of file Event/eformat/include/eformat/PagedMemory.h.

357 {
358 --m_off;
359 if ( m_off < ( m_node->start ) )
360 {
361 if ( !m_node->previous )
362 { // it was the last
363 m_off = m_node->start;
364 return *this;
365 }
366 m_node = m_node->previous;
367 m_off = m_node->end - 1;
368 }
369 return *this;
370}

◆ operator--() [2/3]

template<unsigned int TMAXPAGES = 128>
const_iterator & eformat::PagedMemory< TMAXPAGES >::const_iterator::operator-- ( )

Step back on the pointing place, 4 bytes or 1 word. This is the prefix operator.

◆ operator--() [3/3]

template<unsigned int TMAXPAGES = 128>
const_iterator & eformat::PagedMemory< TMAXPAGES >::const_iterator::operator-- ( )

Step back on the pointing place, 4 bytes or 1 word. This is the prefix operator.

◆ operator-=() [1/3]

template<unsigned int TMAXPAGES>
eformat::PagedMemory< TMAXPAGES >::const_iterator & eformat::PagedMemory< TMAXPAGES >::const_iterator::operator-= ( size_t offset)

Retrocesses on the pointing place, by a number of (32-bit) words

Parameters
offsetThe amount of words to advance

Definition at line 391 of file Event/eformat/include/eformat/PagedMemory.h.

391 {
392 size_t aim = m_off - offset;
393 while ( aim < ( m_node->start ) )
394 {
395 if ( m_node->previous ) m_node = m_node->previous;
396 else
397 { // it was the first
398 m_off = m_node->start;
399 return *this;
400 }
401 }
402 m_off = aim;
403 return *this;
404}

◆ operator-=() [2/3]

template<unsigned int TMAXPAGES = 128>
const_iterator & eformat::PagedMemory< TMAXPAGES >::const_iterator::operator-= ( size_t offset)

Retrocesses on the pointing place, by a number of (32-bit) words

Parameters
offsetThe amount of words to advance

◆ operator-=() [3/3]

template<unsigned int TMAXPAGES = 128>
const_iterator & eformat::PagedMemory< TMAXPAGES >::const_iterator::operator-= ( size_t offset)

Retrocesses on the pointing place, by a number of (32-bit) words

Parameters
offsetThe amount of words to advance

◆ operator<() [1/3]

template<unsigned int TMAXPAGES = 128>
bool eformat::PagedMemory< TMAXPAGES >::const_iterator::operator< ( const const_iterator & other) const
inline

Compares two operators (offset comparison)

Parameters
otherThe other iterator to compare to

Definition at line 210 of file Event/eformat/include/eformat/PagedMemory.h.

210 {
211 return m_off < other.m_off;
212 }

◆ operator<() [2/3]

template<unsigned int TMAXPAGES = 128>
bool eformat::PagedMemory< TMAXPAGES >::const_iterator::operator< ( const const_iterator & other) const
inline

Compares two operators (offset comparison)

Parameters
otherThe other iterator to compare to

Definition at line 210 of file InstallArea/x86_64-el9-gcc13-dbg/include/eformat/PagedMemory.h.

210 {
211 return m_off < other.m_off;
212 }

◆ operator<() [3/3]

template<unsigned int TMAXPAGES = 128>
bool eformat::PagedMemory< TMAXPAGES >::const_iterator::operator< ( const const_iterator & other) const
inline

Compares two operators (offset comparison)

Parameters
otherThe other iterator to compare to

Definition at line 210 of file InstallArea/x86_64-el9-gcc13-opt/include/eformat/PagedMemory.h.

210 {
211 return m_off < other.m_off;
212 }

◆ operator=() [1/3]

template<unsigned int TMAXPAGES = 128>
const_iterator & eformat::PagedMemory< TMAXPAGES >::const_iterator::operator= ( const const_iterator & other)

Copies the value of an iterator

Parameters
otherThe iterator to copy the data from

◆ operator=() [2/3]

template<unsigned int TMAXPAGES = 128>
const_iterator & eformat::PagedMemory< TMAXPAGES >::const_iterator::operator= ( const const_iterator & other)

Copies the value of an iterator

Parameters
otherThe iterator to copy the data from

◆ operator=() [3/3]

template<unsigned int TMAXPAGES = 128>
const_iterator & eformat::PagedMemory< TMAXPAGES >::const_iterator::operator= ( const const_iterator & other)

Copies the value of an iterator

Parameters
otherThe iterator to copy the data from

◆ operator==() [1/3]

template<unsigned int TMAXPAGES = 128>
bool eformat::PagedMemory< TMAXPAGES >::const_iterator::operator== ( const const_iterator & other) const
inline

Compares two pointers

Parameters
otherThe other iterator to compare this one with.

Definition at line 151 of file Event/eformat/include/eformat/PagedMemory.h.

151 {
152 return !( *this != other );
153 }

◆ operator==() [2/3]

template<unsigned int TMAXPAGES = 128>
bool eformat::PagedMemory< TMAXPAGES >::const_iterator::operator== ( const const_iterator & other) const
inline

Compares two pointers

Parameters
otherThe other iterator to compare this one with.

Definition at line 151 of file InstallArea/x86_64-el9-gcc13-dbg/include/eformat/PagedMemory.h.

151 {
152 return !( *this != other );
153 }

◆ operator==() [3/3]

template<unsigned int TMAXPAGES = 128>
bool eformat::PagedMemory< TMAXPAGES >::const_iterator::operator== ( const const_iterator & other) const
inline

Compares two pointers

Parameters
otherThe other iterator to compare this one with.

Definition at line 151 of file InstallArea/x86_64-el9-gcc13-opt/include/eformat/PagedMemory.h.

151 {
152 return !( *this != other );
153 }

◆ operator>() [1/3]

template<unsigned int TMAXPAGES = 128>
bool eformat::PagedMemory< TMAXPAGES >::const_iterator::operator> ( const const_iterator & other) const
inline

Compares two operators (offset comparison)

Parameters
otherThe other iterator to compare to

Definition at line 219 of file Event/eformat/include/eformat/PagedMemory.h.

219 {
220 return m_off > other.m_off;
221 }

◆ operator>() [2/3]

template<unsigned int TMAXPAGES = 128>
bool eformat::PagedMemory< TMAXPAGES >::const_iterator::operator> ( const const_iterator & other) const
inline

Compares two operators (offset comparison)

Parameters
otherThe other iterator to compare to

Definition at line 219 of file InstallArea/x86_64-el9-gcc13-dbg/include/eformat/PagedMemory.h.

219 {
220 return m_off > other.m_off;
221 }

◆ operator>() [3/3]

template<unsigned int TMAXPAGES = 128>
bool eformat::PagedMemory< TMAXPAGES >::const_iterator::operator> ( const const_iterator & other) const
inline

Compares two operators (offset comparison)

Parameters
otherThe other iterator to compare to

Definition at line 219 of file InstallArea/x86_64-el9-gcc13-opt/include/eformat/PagedMemory.h.

219 {
220 return m_off > other.m_off;
221 }

◆ operator[]() [1/3]

template<unsigned int TMAXPAGES>
uint32_t eformat::PagedMemory< TMAXPAGES >::const_iterator::operator[] ( size_t pos) const

Gets a value away N positions from this iterator, unchecked

Parameters
posThe number "N" of positions away from this iterator

Definition at line 308 of file Event/eformat/include/eformat/PagedMemory.h.

308 {
309 if ( m_off + pos < m_node->end )
310 { // trying to reach data on the current page
311 return CAST32( m_node->page->iov_base )[( m_off + pos ) - m_node->start];
312 }
313 // otherwise it is not on this page, I have to find the page
314 const_iterator it = *this;
315 it += pos;
316 return *it;
317}

◆ operator[]() [2/3]

template<unsigned int TMAXPAGES = 128>
uint32_t eformat::PagedMemory< TMAXPAGES >::const_iterator::operator[] ( size_t pos) const

Gets a value away N positions from this iterator, unchecked

Parameters
posThe number "N" of positions away from this iterator

◆ operator[]() [3/3]

template<unsigned int TMAXPAGES = 128>
uint32_t eformat::PagedMemory< TMAXPAGES >::const_iterator::operator[] ( size_t pos) const

Gets a value away N positions from this iterator, unchecked

Parameters
posThe number "N" of positions away from this iterator

◆ PagedMemory

template<unsigned int TMAXPAGES = 128>
PagedMemory
friend

Definition at line 100 of file Event/eformat/include/eformat/PagedMemory.h.

Referenced by PagedMemory.


The documentation for this class was generated from the following files: