container::Queue Class Reference

Abstract base class for all queue containers. More...

#include <queue.h>

Inheritance diagram for container::Queue:

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

Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~Queue ()
void enqueue (Entity *entity)
 Add an Entity onto the end of the Queue.
Entitydequeue ()
 Remove the first Entity from the Queue and return a pointer to the Entity.
int purgeContents ()
 Empty the contents of the container, deleting all Entities.
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 =0
 A polymorphic copy constructor.

Static Public Attributes

static const Info *const TYPE_INFO = Object::typeInfoFactory("Queue")

Protected Member Functions

 Queue ()
 Queue (const Queue &orig)
virtual void enqueue_impl (Entity *entity)=0
 Called by a template method.
virtual Entitydequeue_impl ()=0
 Called by a template method.

Private Member Functions

void setCount (int c)
 Hide from sub-classes.
void incCount ()
 Hide from sub-classes.
void decCount ()
 Hide from sub-classes.


Detailed Description

Abstract base class for all queue containers.

Allows duplicates. Is unbounded.


Constructor & Destructor Documentation

container::Queue::Queue (  )  [protected]

00047 { }

container::Queue::Queue ( const Queue orig  )  [protected]

00049 : Container(orig) { }

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

00051 { }


Member Function Documentation

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

A polymorphic copy constructor.

Implements container::Container.

Implemented in container::QueueImpl.

Here is the caller graph for this function:

void container::Queue::decCount (  )  [inline, private]

Hide from sub-classes.

Reimplemented from container::Container.

00151                           {
00152       Container::decCount();
00153    }

Here is the caller graph for this function:

Entity * container::Queue::dequeue (  ) 

Remove the first Entity from the Queue and return a pointer to the Entity.

A template method that calls the dequeue_impl method of the the derived class.

Returns:
A pointer to the Entity that was removed from the first position of the queue
Precondition:
There is at least one item in the Queue
Postcondition:
The Entity (formerly the first item) is not in the list

The caller is responsible for deleting the extracted Entity

The Container's count is lesser by one

If the Queue had 2 or more items, then the formerly 2nd Entity is the first item

If the Queue had only 1 item, then the Queue is empty

00063                         {
00064    if (getCount() == 0) {
00065       return NULL;
00066    }
00067    Entity * e = dequeue_impl();
00068    decCount();
00069    return e;
00070 }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Called by a template method.

See also:
Details documented in method dequeue

Implemented in container::QueueImpl.

Here is the caller graph for this function:

void container::Queue::enqueue ( Entity entity  ) 

Add an Entity onto the end of the Queue.

A template method that calls the enqueue_impl method of the the derived class.

Precondition:
The specified entity pointer is not null
Postcondition:
If there were already 1 or more items in the queue, the specified entity is the last item in the Queue

If the queue was empty, the specified entity can be considered to be both the first and last item in the queue

The Container's count is greater by one

00055                                   {
00056    if (entity == NULL) {
00057       return;
00058    }
00059    enqueue_impl(entity);
00060    incCount();
00061 }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Called by a template method.

See also:
Details documented in method enqueue

Implemented in container::QueueImpl.

Here is the caller graph for this function:

void container::Queue::incCount (  )  [inline, private]

Hide from sub-classes.

Reimplemented from container::Container.

00144                           {
00145       Container::incCount();
00146    }

Here is the caller graph for this function:

int container::Queue::purgeContents (  )  [virtual]

Empty the contents of the container, deleting all Entities.

This method is used by the destructor.

Returns:
The number of Entity objects deleted
Postcondition:
isEmpty() is true

The memory for all Entities is freed

Implements container::Container.

00074                          {
00075    int n = 0;
00076    for (Entity* e = dequeue(); e != NULL; e = dequeue()) {
00077       delete e;
00078       n++;
00079    }
00080    return n;
00081 }

Here is the call graph for this function:

Here is the caller graph for this function:

ostream & container::Queue::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::Container.

Reimplemented in container::QueueImpl.

00085                                               {
00086    return this->Container::renderState(os);
00087 }

void container::Queue::setCount ( int  c  )  [inline, private]

Hide from sub-classes.

Reimplemented from container::Container.

00137                                {
00138       Container::setCount(c);
00139    }

const Object::Info * container::Queue::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::Container.

Reimplemented in container::QueueImpl.

00089                                         {
00090    return TYPE_INFO;
00091 }

Here is the caller graph for this function:


Member Data Documentation

const Object::Info *const container::Queue::TYPE_INFO = Object::typeInfoFactory("Queue") [static]

Reimplemented from container::Container.

Reimplemented in container::QueueImpl.


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