#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 |
Private Member Functions | |
const_iterator (const node_t *node, size_t offset) | |
Private Attributes | |
const node_t * | m_node |
base address of the index table | |
size_t | m_off |
the current offset, in 32-bit words | |
Friends | |
class | PagedMemory |
Definition at line 101 of file PagedMemory.h.
eformat::PagedMemory< TMAXPAGES >::const_iterator::const_iterator | ( | const node_t * | node, | |
size_t | offset | |||
) | [inline, private] |
Builds a new iterator giving an index and an offset inside that index.
base | The base address of the memory block being pointed now | |
size | The total size of this block, in 32-bit words | |
offset | The offset to where I should point to, in 32-bit words |
Definition at line 115 of file PagedMemory.h.
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 125 of file PagedMemory.h.
eformat::PagedMemory< TMAXPAGES >::const_iterator::const_iterator | ( | const const_iterator & | other | ) | [inline] |
eformat::PagedMemory< TMAXPAGES >::const_iterator::~const_iterator | ( | ) | [inline] |
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
pos | The number "N" of positions away from this iterator |
Definition at line 330 of file PagedMemory.h.
References eformat::PagedMemory< TMAXPAGES >::const_iterator::at(), CAST32, EFORMAT_OUT_OF_BOUNDS, eformat::PagedMemory< TMAXPAGES >::node_t::end, eformat::PagedMemory< TMAXPAGES >::end(), eformat::PagedMemory< TMAXPAGES >::const_iterator::m_node, eformat::PagedMemory< TMAXPAGES >::const_iterator::m_off, eformat::PagedMemory< TMAXPAGES >::node_t::next, eformat::PagedMemory< TMAXPAGES >::node_t::page, and eformat::PagedMemory< TMAXPAGES >::node_t::start.
Referenced by eformat::PagedMemory< TMAXPAGES >::const_iterator::at().
00331 { 00332 //immediate return (most of the cases) 00333 if (m_off + pos < m_node->end) { //trying to reach data on the current page 00334 return CAST32(m_node->page->iov_base)[(m_off+pos)-m_node->start]; 00335 } 00336 00337 //immediate points of failure 00338 if (!m_node || (m_node->next == 0 && (m_off+pos) >= m_node->end)) 00339 throw EFORMAT_OUT_OF_BOUNDS(0, pos << 2); 00340 00341 //if I get here, the data is on another page and the request might still be 00342 //out of bounds, so watch. 00343 const_iterator it = *this; 00344 it += pos; 00345 return it.at(0); 00346 }
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 182 of file PagedMemory.h.
References CAST32, eformat::PagedMemory< TMAXPAGES >::const_iterator::m_node, eformat::PagedMemory< TMAXPAGES >::const_iterator::m_off, eformat::PagedMemory< TMAXPAGES >::node_t::page, and eformat::PagedMemory< TMAXPAGES >::node_t::start.
bool eformat::PagedMemory< TMAXPAGES >::const_iterator::operator!= | ( | const const_iterator & | other | ) | const |
Compares two pointers
other | The other iterator to compare this one with. |
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 349 of file PagedMemory.h.
References eformat::PagedMemory< TMAXPAGES >::node_t::end, eformat::PagedMemory< TMAXPAGES >::const_iterator::m_node, eformat::PagedMemory< TMAXPAGES >::const_iterator::m_off, eformat::PagedMemory< TMAXPAGES >::node_t::next, and eformat::PagedMemory< TMAXPAGES >::node_t::start.
00350 { 00351 ++m_off; 00352 if ( m_off >= (m_node->end) ) { 00353 if (!m_node->next) { //it was the last 00354 m_off = m_node->end; 00355 return *this; 00356 } 00357 m_node = m_node->next; 00358 m_off = m_node->start; 00359 } 00360 return *this; 00361 }
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
offset | The amount of words to advance |
Definition at line 379 of file PagedMemory.h.
References eformat::PagedMemory< TMAXPAGES >::node_t::end, eformat::PagedMemory< TMAXPAGES >::const_iterator::m_node, eformat::PagedMemory< TMAXPAGES >::const_iterator::m_off, and eformat::PagedMemory< TMAXPAGES >::node_t::next.
00380 { 00381 size_t aim = offset + m_off; 00382 while (aim >= (m_node->end)) { 00383 if (m_node->next) m_node = m_node->next; 00384 else { //it was the last 00385 m_off = m_node->end; 00386 return *this; 00387 } 00388 } 00389 m_off = aim; 00390 return *this; 00391 }
int32_t eformat::PagedMemory< TMAXPAGES >::const_iterator::operator- | ( | const const_iterator & | other | ) | const [inline] |
Returns the difference in position between two iterators
other | The other iterator to compare to |
Definition at line 232 of file PagedMemory.h.
References eformat::PagedMemory< TMAXPAGES >::const_iterator::m_off, and EvtCyclic3::other().
eformat::PagedMemory< TMAXPAGES >::const_iterator & eformat::PagedMemory< TMAXPAGES >::const_iterator::operator-- | ( | ) |
Step back on the pointing place, 4 bytes or 1 word. This is the prefix operator.
Definition at line 364 of file PagedMemory.h.
References eformat::PagedMemory< TMAXPAGES >::node_t::end, eformat::PagedMemory< TMAXPAGES >::const_iterator::m_node, eformat::PagedMemory< TMAXPAGES >::const_iterator::m_off, eformat::PagedMemory< TMAXPAGES >::node_t::previous, and eformat::PagedMemory< TMAXPAGES >::node_t::start.
00365 { 00366 --m_off; 00367 if ( m_off < (m_node->start) ) { 00368 if (!m_node->previous) { //it was the last 00369 m_off = m_node->start; 00370 return *this; 00371 } 00372 m_node = m_node->previous; 00373 m_off = m_node->end - 1; 00374 } 00375 return *this; 00376 }
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
offset | The amount of words to advance |
Definition at line 394 of file PagedMemory.h.
References eformat::PagedMemory< TMAXPAGES >::const_iterator::m_node, eformat::PagedMemory< TMAXPAGES >::const_iterator::m_off, eformat::PagedMemory< TMAXPAGES >::node_t::previous, and eformat::PagedMemory< TMAXPAGES >::node_t::start.
00395 { 00396 size_t aim = m_off - offset; 00397 while (aim < (m_node->start)) { 00398 if (m_node->previous) m_node = m_node->previous; 00399 else { //it was the first 00400 m_off = m_node->start; 00401 return *this; 00402 } 00403 } 00404 m_off = aim; 00405 return *this; 00406 }
bool eformat::PagedMemory< TMAXPAGES >::const_iterator::operator< | ( | const const_iterator & | other | ) | const [inline] |
Compares two operators (offset comparison)
other | The other iterator to compare to |
Definition at line 216 of file PagedMemory.h.
References eformat::PagedMemory< TMAXPAGES >::const_iterator::m_off, and EvtCyclic3::other().
const_iterator& eformat::PagedMemory< TMAXPAGES >::const_iterator::operator= | ( | const const_iterator & | other | ) |
Copies the value of an iterator
other | The iterator to copy the data from |
bool eformat::PagedMemory< TMAXPAGES >::const_iterator::operator== | ( | const const_iterator & | other | ) | const [inline] |
Compares two pointers
other | The other iterator to compare this one with. |
Definition at line 159 of file PagedMemory.h.
References EvtCyclic3::other().
00160 { return !(*this != other); }
bool eformat::PagedMemory< TMAXPAGES >::const_iterator::operator> | ( | const const_iterator & | other | ) | const [inline] |
Compares two operators (offset comparison)
other | The other iterator to compare to |
Definition at line 224 of file PagedMemory.h.
References eformat::PagedMemory< TMAXPAGES >::const_iterator::m_off, and EvtCyclic3::other().
uint32_t eformat::PagedMemory< TMAXPAGES >::const_iterator::operator[] | ( | size_t | pos | ) | const |
Gets a value away N positions from this iterator, unchecked
pos | The number "N" of positions away from this iterator |
Definition at line 318 of file PagedMemory.h.
References CAST32, deljobs::end, and boss::pos.
00319 { 00320 if (m_off + pos < m_node->end) { //trying to reach data on the current page 00321 return CAST32(m_node->page->iov_base)[(m_off+pos)-m_node->start]; 00322 } 00323 //otherwise it is not on this page, I have to find the page 00324 const_iterator it = *this; 00325 it += pos; 00326 return *it; 00327 }
friend class PagedMemory [friend] |
Definition at line 105 of file PagedMemory.h.
const node_t* eformat::PagedMemory< TMAXPAGES >::const_iterator::m_node [private] |
base address of the index table
Definition at line 237 of file PagedMemory.h.
Referenced by eformat::PagedMemory< TMAXPAGES >::const_iterator::at(), eformat::PagedMemory< TMAXPAGES >::const_iterator::operator *(), eformat::PagedMemory< TMAXPAGES >::const_iterator::operator++(), eformat::PagedMemory< TMAXPAGES >::const_iterator::operator+=(), eformat::PagedMemory< TMAXPAGES >::const_iterator::operator--(), and eformat::PagedMemory< TMAXPAGES >::const_iterator::operator-=().
size_t eformat::PagedMemory< TMAXPAGES >::const_iterator::m_off [private] |
the current offset, in 32-bit words
Definition at line 238 of file PagedMemory.h.
Referenced by eformat::PagedMemory< TMAXPAGES >::const_iterator::at(), eformat::PagedMemory< TMAXPAGES >::const_iterator::operator *(), eformat::PagedMemory< TMAXPAGES >::const_iterator::operator++(), eformat::PagedMemory< TMAXPAGES >::const_iterator::operator+=(), eformat::PagedMemory< TMAXPAGES >::const_iterator::operator-(), eformat::PagedMemory< TMAXPAGES >::const_iterator::operator--(), eformat::PagedMemory< TMAXPAGES >::const_iterator::operator-=(), eformat::PagedMemory< TMAXPAGES >::const_iterator::operator<(), and eformat::PagedMemory< TMAXPAGES >::const_iterator::operator>().