Fawkes API  Fawkes Development Version
fawkes::BlackBoardMemoryManager::ChunkIterator Class Reference

Iterator for memory chunks. More...

#include <>>

Public Member Functions

 ChunkIterator ()
 Constructor. More...
 
 ChunkIterator (const ChunkIterator &it)
 Copy constructor. More...
 
ChunkIteratoroperator++ ()
 Increment iterator. More...
 
ChunkIterator operator++ (int inc)
 Increment iterator. More...
 
ChunkIteratoroperator+ (unsigned int i)
 Advance by a certain amount. More...
 
ChunkIteratoroperator+= (unsigned int i)
 Advance by a certain amount. More...
 
bool operator== (const ChunkIterator &c) const
 Check equality of two iterators. More...
 
bool operator!= (const ChunkIterator &c) const
 Check inequality of two iterators. More...
 
void * operator* () const
 Get memory pointer of chunk. More...
 
ChunkIteratoroperator= (const ChunkIterator &c)
 Assign iterator. More...
 
unsigned int size () const
 Get size of data segment. More...
 
unsigned int overhang () const
 Get number of overhanging bytes. More...
 

Friends

class BlackBoardMemoryManager
 

Detailed Description

Iterator for memory chunks.

The ChunkIterator can be used to iterate over all allocated memory chunks in the memory segment.

Definition at line 100 of file memory_manager.h.

Constructor & Destructor Documentation

◆ ChunkIterator() [1/2]

fawkes::BlackBoardMemoryManager::ChunkIterator::ChunkIterator ( )

Constructor.

Will create a instance pointing beyond the end of the lits.

Definition at line 905 of file memory_manager.cpp.

◆ ChunkIterator() [2/2]

fawkes::BlackBoardMemoryManager::ChunkIterator::ChunkIterator ( const ChunkIterator it)

Copy constructor.

Parameters
itIterator to copy

Definition at line 936 of file memory_manager.cpp.

Member Function Documentation

◆ operator!=()

bool fawkes::BlackBoardMemoryManager::ChunkIterator::operator!= ( const ChunkIterator c) const

Check inequality of two iterators.

Can be used to determine if two iterators point to different chunks.

Parameters
citerator to compare current instance to
Returns
true, if iterators point to different chunks of memory, false otherwise

Definition at line 1039 of file memory_manager.cpp.

◆ operator*()

void * fawkes::BlackBoardMemoryManager::ChunkIterator::operator* ( ) const

Get memory pointer of chunk.

Use this operator to get the pointer to the chunk of memory that this iterator points to.

Returns
pointer to memory

Definition at line 1051 of file memory_manager.cpp.

References fawkes::SharedMemory::ptr().

◆ operator+()

BlackBoardMemoryManager::ChunkIterator & fawkes::BlackBoardMemoryManager::ChunkIterator::operator+ ( unsigned int  i)

Advance by a certain amount.

Can be used to add an integer to the iterator to advance many steps in one go. This operation takes linear time depending on i.

Parameters
isteps to advance in list. If i is bigger than the number of remaining elements in the list will stop beyond list.
Returns
reference to current instance after advancing i steps or after reaching end of list.

Definition at line 996 of file memory_manager.cpp.

◆ operator++() [1/2]

BlackBoardMemoryManager::ChunkIterator & fawkes::BlackBoardMemoryManager::ChunkIterator::operator++ ( )

Increment iterator.

Advances to the next element. This is the infix-operator. It may be used like this:

for (ChunkIterator cit = memmgr->begin(); cit != memmgr->end(); ++cit) {
// your code here
}
Returns
Reference to instance itself after advancing to the next element.

Definition at line 954 of file memory_manager.cpp.

◆ operator++() [2/2]

BlackBoardMemoryManager::ChunkIterator fawkes::BlackBoardMemoryManager::ChunkIterator::operator++ ( int  inc)

Increment iterator.

Advances to the next element in allocated chunk list. This is the postfix-operator. It may be used like this:

for (ChunkIterator cit = memmgr->begin(); cit != memmgr->end(); cit++) {
// your code here
}

Note that since a copy of the original iterator has to be created an returned it the postfix operation takes both, more CPU time and more memory. If possible (especially if used in a for loop like the example) use the prefix operator!

See also
operator++()
Parameters
incignored
Returns
copy of the current instance before advancing to the next element.

Definition at line 978 of file memory_manager.cpp.

◆ operator+=()

BlackBoardMemoryManager::ChunkIterator & fawkes::BlackBoardMemoryManager::ChunkIterator::operator+= ( unsigned int  i)

Advance by a certain amount.

Works like operator+(unsigned int i), provided for convenience.

Parameters
isteps to advance in list
Returns
reference to current instance after advancing i steps or after reaching end of list.

Definition at line 1012 of file memory_manager.cpp.

◆ operator=()

BlackBoardMemoryManager::ChunkIterator & fawkes::BlackBoardMemoryManager::ChunkIterator::operator= ( const ChunkIterator c)

Assign iterator.

Makes the current instance to point to the same memory element as c.

Parameters
cassign value
Returns
reference to current instance

Definition at line 1066 of file memory_manager.cpp.

◆ operator==()

bool fawkes::BlackBoardMemoryManager::ChunkIterator::operator== ( const ChunkIterator c) const

Check equality of two iterators.

Can be used to determine if two iterators point to the same chunk.

Parameters
citerator to compare current instance to
Returns
true, if iterators point to the same chunk, false otherwise

Definition at line 1027 of file memory_manager.cpp.

◆ overhang()

unsigned int fawkes::BlackBoardMemoryManager::ChunkIterator::overhang ( ) const

Get number of overhanging bytes.

See documentation of BlackBoardMemoryManager about overhanging bytes.

See also
BlackBoardMemoryManager
Returns
number of overhanging bytes.

Definition at line 1091 of file memory_manager.cpp.

◆ size()

unsigned int fawkes::BlackBoardMemoryManager::ChunkIterator::size ( ) const

Get size of data segment.

Returns the size of the memory chunk. This includes overhanging bytes.

Returns
size of chunk including overhanging bytes

Definition at line 1079 of file memory_manager.cpp.


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