class Fifo_iterator

Class Fifo_iterator: Enables access to the Fifos while hiding their implementation in shared memory.

Public Methods

[more] creator and destructor of the iterators
[more] Member function that iterate over the fifos in the system
[more] Operators on the fifo iterator


Documentation

Class Fifo_iterator: Enables access to the Fifos while hiding their implementation in shared memory.

The Fifos reside in shared memory as a fixed length array. An available slot may or may not be occupied by a Fifo. Fifo_iterator allows to iterate in forward direction over the occpupied slots (the unoccupied slots are ignored).

A typical use of the iterator is as follows:


    // creates an initialises the iterator to the INPUT fifo
    Fifo_iterator it_inp(fifos, "INPUT");
    if ( ! it_inp.valid() )
       cout << "INPUT fifo not found";

    // creates an arbitrary iterator - fifos is a pointer to the Fifo_system
    Fifo_iterator it( fifos );
    // iterates over the all the fifos of the system fifos
    for ( it.first(); ! it.is_done(); it.next() ) {
       if ( ! (*it)->in_use() ) {
          // this should never happen as we iterate only over the fifos
          // that are in use !
       }
       if ( it != it_inp ) {
          // do something
       }
    }
    

Modifications:

o creator and destructor of the iterators

o Fifo_iterator( Fifo_system* the_system)
Constructor for an iterator on the fifo system the_system.
Parameters:
the_system - : Pointer to the fifo system where the fifos are located
Returns:
Pointer to the first fifo that is in use or an iterator that is bigger than the iterator last.

o Fifo_iterator( Fifo_system* the_system, const char* fifo_name)
Constructor for an iterator that points to the fifo with name fifo_name.
Parameters:
the_system - : Pointer to the fifo system where the fifos are located
Returns:
Pointer to the fifo fifo_name or an iterator that is bigger than the iterator last.

o Fifo_iterator( Fifo_iterator*)
Copy constructor: Initialises the iterator to the same fifo as iterator.
Parameters:
- Fifo_iterator a valid fifo iterator
Returns:
Iterator to the same fifo.

o Member function that iterate over the fifos in the system

ovoid first()
Puts the iterator on the first fifo that is in use

ovoid last()
Puts the iterator on the last fifo that is in use

ovoid next()
Increments the iterator to the next fifo (or makes it bigger than last)

oint is_valid() const
Returns -1 if the fifo iterator points to a valid fifo. A valid fifo defined as one that resides between the first and the last iterator.

oint is_done() const
Returns -1 if the iterator is bigger than last

oFifo_iterator& operator++()
Same as next - for convenience only

o Operators on the fifo iterator

oFifo_iterator& operator=(const Fifo_iterator &rhs)
Assignment operator - assigns the lhs iterator to the rhs. Note: This can change the fifo_system to which the lhs iterator originally pointed to.

oFifo* get_fifo() const
Dereferences the iterator: Returns a pointer to the Fifo to which the iterator points

oFifo* operator*() const
Dereferences the iterator: Returns a pointer to the Fifo to which the iterator points

oBOOL operator==(const Fifo_iterator &rhs ) const
Overloaded == operator. Returns true if the iterator points to the same fifo in the same system.

oBOOL operator!=(const Fifo_iterator &rhs ) const
Overloaded != operator. Returns true if the iterator points to a different fifo in a possibly different system.


This class has no child classes.
Author:
C.Witzig
Date: Nov 30, 1997
Version:
Last update: Nov 30, 1997

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.