container::QueueImpl Class Reference

An implementation of Queue that based on an OrderedList. More...

#include <queueimpl.h>

Inheritance diagram for container::QueueImpl:

Inheritance graph
[legend]
Collaboration diagram for container::QueueImpl:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 QueueImpl (const QueueImpl &orig)
 QueueImpl (const QueueImpl &orig, bool deepCopy)
virtual ~QueueImpl ()
virtual ostream & renderState (ostream &os) const
 Write the state of an Object for debugging and demonstration.
virtual const InfotypeInfo () const
 Return the instance of Object::Info that describes the class of this object.
virtual Objectclone (bool deepCopy=false) const
 A polymorphic copy constructor.

Static Public Member Functions

static QueuefactoryLinkedComposition ()
 Constructs an QueueImpl with an underlying OrderedLinkedList.
static QueuefactoryArrayComposition ()
 Constructs a QueueImpl with an underlying OrderedArrayList.

Static Public Attributes

static const Info *const TYPE_INFO

Protected Member Functions

virtual void enqueue_impl (Entity *entity)
 Called by a template method.
virtual Entitydequeue_impl ()
 Called by a template method.

Private Member Functions

 QueueImpl (OrderedList *list)

Private Attributes

OrderedList *const list


Detailed Description

An implementation of Queue that based on an OrderedList.

Two factory methods are provided: factoryLinkedComposition() and factoryArrayComposition(). The first creates a Queue with an underlying OrderedLinkedList and the second with an underlying OrderedArrayList. Since both satisfy the OrderedList contract, no special handling was required for the either type.


Constructor & Destructor Documentation

container::QueueImpl::QueueImpl ( OrderedList list  )  [private]

00050 : list(lst) { }

Here is the caller graph for this function:

container::QueueImpl::QueueImpl ( const QueueImpl orig  ) 

00052                                          : Queue(orig),
00053 list(dynamic_cast<OrderedList * const>(orig.list->clone())) { }

container::QueueImpl::QueueImpl ( const QueueImpl orig,
bool  deepCopy 
)

00055                                                         : Queue(orig),
00056 list(dynamic_cast<OrderedList * const>(orig.list->clone(deepCopy))) { }

container::QueueImpl::~QueueImpl (  )  [virtual]

00058                       {
00059    delete list;
00060 }


Member Function Documentation

Object * container::QueueImpl::clone ( bool  deepCopy = false  )  const [virtual]

A polymorphic copy constructor.

Implements container::Queue.

00111                                             {
00112    return new QueueImpl(*this, deepCopy);
00113 }

Here is the call graph for this function:

Entity * container::QueueImpl::dequeue_impl (  )  [protected, virtual]

Called by a template method.

See also:
Details documented in method dequeue

Implements container::Queue.

00078                                  {
00079    if (list->toFirst()) {
00080       return list->extractCurrentEntity();
00081    } else {
00082       return NULL;
00083    }
00084 }

Here is the call graph for this function:

void container::QueueImpl::enqueue_impl ( Entity entity  )  [protected, virtual]

Called by a template method.

See also:
Details documented in method enqueue

Implements container::Queue.

00074                                            {
00075    list->append(entity);
00076 }

Here is the call graph for this function:

Queue * container::QueueImpl::factoryArrayComposition (  )  [static]

Constructs a QueueImpl with an underlying OrderedArrayList.

00068                                           {
00069    return new QueueImpl(new OrderedArrayList());
00070 }

Here is the call graph for this function:

Queue * container::QueueImpl::factoryLinkedComposition (  )  [static]

Constructs an QueueImpl with an underlying OrderedLinkedList.

00064                                            {
00065    return new QueueImpl(new OrderedLinkedList());
00066 }

Here is the call graph for this function:

ostream & container::QueueImpl::renderState ( ostream &  os  )  const [virtual]

Write the state of an Object for debugging and demonstration.

This method must not change the state of an Object; adding or removing debug statements should not change the behavior of a class. The implementation must be robust, e.g., NULL safe, etc. and work without an unrecoverable error for any state, excluding an Object's time of construction and destruction. It is not required for the implementation to be thread safe.

Precondition:
The Object has been fully constructed and is not in the process of destruction
Postcondition:
The state of the Object is unchanged

Reimplemented from container::Queue.

00088                                                   {
00089 
00090    this->Queue::renderState(os);
00091    os << " composed with an " << list->typeInfo()->typeName << " contents{";
00092    int i = 0;
00093    for (list->toFirst(); !list->isTail(); list->toNext()) {
00094       os << std::endl << "      [" << i << ']' << list->currentEntity();
00095       if (list->getCount() > 1) {
00096          if (list->isFirst()) {
00097             os << " <--FIRST";
00098          } else if (list->isLast()) {
00099             os << " <--LAST";
00100          }
00101       }
00102       i++;
00103    }
00104    return os << "}";
00105 }

Here is the call graph for this function:

const Object::Info * container::QueueImpl::typeInfo (  )  const [virtual]

Return the instance of Object::Info that describes the class of this object.

Instantiation of Object::Info is controlled by the protected method Object::typeInfoFactory(const string&). Each sub-class of Object should create one and only one instance of Object::Info.

Reimplemented from container::Queue.

00107                                             {
00108    return TYPE_INFO;
00109 }


Member Data Documentation

Initial value:

Reimplemented from container::Queue.


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

Generated on Tue Jun 16 23:13:00 2009 by  doxygen 1.5.9