Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

eformat::PagedMemory< TMAXPAGES >::const_iterator Class Reference

#include <PagedMemory.h>

List of all members.

Public Member Functions

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

Private Member Functions

 const_iterator (const node_t *node, size_t offset)
 const_iterator (const node_t *node, size_t offset)

Private Attributes

const node_tm_node
 base address of the index table
const node_tm_node
 base address of the index table
size_t m_off
 the current offset, in 32-bit words

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()


Constructor & Destructor Documentation

template<unsigned int TMAXPAGES = 128>
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.

Parameters:
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
00116         : m_node(node), m_off(offset) {}

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.

00125 : m_node(), m_off() {}

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

Copies the value of an iterator

Parameters:
other The iterator to copy the data from
00133         : m_node(other.m_node), m_off(other.m_off) {}

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

Destroys an iterator

00138 {}

template<unsigned int TMAXPAGES = 128>
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.

Parameters:
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
00116         : m_node(node), m_off(offset) {}

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.

00125 : m_node(), m_off() {}

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

Copies the value of an iterator

Parameters:
other The iterator to copy the data from
00133         : m_node(other.m_node), m_off(other.m_off) {}

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

Destroys an iterator

00138 {}


Member Function Documentation

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:
pos The number "N" of positions away from this iterator

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:
pos The number "N" of positions away from this iterator
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 }

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().

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

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().

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

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

Compares two pointers

Parameters:
other The other iterator to compare this one with.

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

Compares two pointers

Parameters:
other The other iterator to compare this one with.

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.

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.

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 }

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:
offset The amount of words to advance

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:
offset The amount of words to advance
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 }

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:
other The other iterator to compare to
00233       { return (int32_t)m_off - (int32_t)other.m_off; }

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:
other The other iterator to compare to
00233       { return (int32_t)m_off - (int32_t)other.m_off; }

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.

template<unsigned int TMAXPAGES>
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.

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 }

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:
offset The amount of words to advance

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:
offset The amount of words to advance
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 }

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

Compares two operators (offset comparison)

Parameters:
other The other iterator to compare to
00217       { return m_off < other.m_off; }

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

Compares two operators (offset comparison)

Parameters:
other The other iterator to compare to
00217       { return m_off < other.m_off; }

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

Copies the value of an iterator

Parameters:
other The iterator to copy the data from

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

Copies the value of an iterator

Parameters:
other The iterator to copy the data from

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

Compares two pointers

Parameters:
other The other iterator to compare this one with.
00160       { return !(*this != other); }

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

Compares two pointers

Parameters:
other The other iterator to compare this one with.
00160       { return !(*this != other); }

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

Compares two operators (offset comparison)

Parameters:
other The other iterator to compare to
00225       { return m_off > other.m_off; }

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

Compares two operators (offset comparison)

Parameters:
other The other iterator to compare to
00225       { return m_off > other.m_off; }

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:
pos The number "N" of positions away from this iterator

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:
pos The number "N" of positions away from this iterator
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 }


Friends And Related Function Documentation

template<unsigned int TMAXPAGES = 128>
PagedMemory [friend]
 


Member Data Documentation

template<unsigned int TMAXPAGES = 128>
const node_t* eformat::PagedMemory< TMAXPAGES >::const_iterator::m_node [private]
 

base address of the index table

template<unsigned int TMAXPAGES = 128>
const node_t* eformat::PagedMemory< TMAXPAGES >::const_iterator::m_node [private]
 

base address of the index table

template<unsigned int TMAXPAGES = 128>
size_t eformat::PagedMemory< TMAXPAGES >::const_iterator::m_off [private]
 

the current offset, in 32-bit words


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 19:18:07 2011 for BOSS6.5.5 by  doxygen 1.3.9.1