fawkes::MessageQueue::MessageIterator Class Reference

Message iterator. More...

#include <interface/message_queue.h>

List of all members.

Public Member Functions

 MessageIterator ()
 Constructor.
 MessageIterator (const MessageIterator &it)
 Copy constructor.
MessageIteratoroperator++ ()
 Increment iterator.
MessageIterator operator++ (int inc)
 Increment iterator.
MessageIteratoroperator+ (unsigned int i)
 Advance by a certain amount.
MessageIteratoroperator+= (unsigned int i)
 Advance by a certain amount.
bool operator== (const MessageIterator &c) const
 Check equality of two iterators.
bool operator!= (const MessageIterator &c) const
 Check inequality of two iterators.
Messageoperator* () const
 Get memory pointer of chunk.
Messageoperator-> () const
 Act on current message.
MessageIteratoroperator= (const MessageIterator &c)
 Assign iterator.
unsigned int id () const
 Get ID of current element or 0 if element is end.
template<class MessageType >
bool is () const
 Check if message is of given type.
template<class MessageType >
MessageType * get () const
 Get current message of given type.

Friends

class MessageQueue

Detailed Description

Message iterator.

Use this iterator to iterate over messages in a message queue. Use MessageQueue::begin() to get the iterator.

Author:
Tim Niemueller

Definition at line 58 of file message_queue.h.


Constructor & Destructor Documentation

fawkes::MessageQueue::MessageIterator::MessageIterator (  ) 

Constructor.

Definition at line 372 of file message_queue.cpp.

fawkes::MessageQueue::MessageIterator::MessageIterator ( const MessageIterator it  ) 

Copy constructor.

Parameters:
it Iterator to copy

Definition at line 381 of file message_queue.cpp.


Member Function Documentation

template<class MessageType >
MessageType * fawkes::MessageQueue::MessageIterator::get (  )  const [inline]

Get current message of given type.

This will return the current message of the given template type. An TypeMismatchException is thrown if the current message is not of the requested type.

Exceptions:
TypeMismatchException thrown, if current message is not of requested type.
Returns:
current message of requested type

Definition at line 140 of file message_queue.h.

unsigned int fawkes::MessageQueue::MessageIterator::id (  )  const

Get ID of current element or 0 if element is end.

Returns:
ID of current element or 0 if element is end.

Definition at line 531 of file message_queue.cpp.

template<class MessageType >
bool fawkes::MessageQueue::MessageIterator::is (  )  const [inline]

Check if message is of given type.

The current message is checked if it is of the type that the template parameter determines. Use non-pointer template arguments!

Returns:
true, if the current message is of the given type, false otherwise

Definition at line 125 of file message_queue.h.

bool fawkes::MessageQueue::MessageIterator::operator!= ( const MessageIterator c  )  const

Check inequality of two iterators.

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

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

Definition at line 485 of file message_queue.cpp.

Message * fawkes::MessageQueue::MessageIterator::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 497 of file message_queue.cpp.

MessageQueue::MessageIterator & fawkes::MessageQueue::MessageIterator::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:
i steps 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 442 of file message_queue.cpp.

MessageQueue::MessageIterator fawkes::MessageQueue::MessageIterator::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 (MessageIterator 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:
inc ignored
Returns:
copy of the current instance before advancing to the next element.

Definition at line 423 of file message_queue.cpp.

MessageQueue::MessageIterator & fawkes::MessageQueue::MessageIterator::operator++ (  ) 

Increment iterator.

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

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

Definition at line 398 of file message_queue.cpp.

MessageQueue::MessageIterator & fawkes::MessageQueue::MessageIterator::operator+= ( unsigned int  i  ) 

Advance by a certain amount.

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

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

Definition at line 458 of file message_queue.cpp.

Message * fawkes::MessageQueue::MessageIterator::operator-> (  )  const

Act on current message.

Node that you have to make sure that this is not called on the end node!

Returns:
current message

Definition at line 508 of file message_queue.cpp.

MessageQueue::MessageIterator & fawkes::MessageQueue::MessageIterator::operator= ( const MessageIterator c  ) 

Assign iterator.

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

Parameters:
c assign value
Returns:
reference to current instance

Definition at line 520 of file message_queue.cpp.

bool fawkes::MessageQueue::MessageIterator::operator== ( const MessageIterator c  )  const

Check equality of two iterators.

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

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

Definition at line 473 of file message_queue.cpp.


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

Generated on 1 Mar 2011 for Fawkes API by  doxygen 1.6.1