container::Container Class Reference

Abstract base class for all containers. More...

#include <container.h>

Inheritance diagram for container::Container:

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

Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~Container ()
int getCount () const
 Return the number of Entity objects in this container.
bool isEmpty () const
 Return true if the container is empty, false otherwise.
virtual int purgeContents ()=0
 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("Container")

Protected Member Functions

 Container ()
 Container (const Container &orig)
void setCount (int c)
void incCount ()
void decCount ()

Private Attributes

int count
 Number of Entity objects in this Container.


Detailed Description

Abstract base class for all containers.

Todo:
Pull up all common functionality from derived classes.

Constructor & Destructor Documentation

container::Container::Container (  )  [protected]

00047 : count(0) { }

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

00049 : count(orig.count) { }

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

00051 { }


Member Function Documentation

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

void container::Container::decCount (  )  [protected]

Reimplemented in container::OrderedList, container::Queue, container::SortedList, and container::Stack.

00073                          {
00074    count--;
00075 }

Here is the caller graph for this function:

int container::Container::getCount (  )  const

Return the number of Entity objects in this container.

00055                               {
00056    return count;
00057 }

Here is the caller graph for this function:

void container::Container::incCount (  )  [protected]

Reimplemented in container::OrderedList, container::Queue, container::SortedList, and container::Stack.

00069                          {
00070    count++;
00071 }

Here is the caller graph for this function:

bool container::Container::isEmpty (  )  const

Return true if the container is empty, false otherwise.

00059                               {
00060    return getCount() == 0;
00061 }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual int container::Container::purgeContents (  )  [pure 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

Implemented in container::List, container::Queue, and container::Stack.

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

Reimplemented in container::ArrayList, container::LinkedList, container::List, container::OrderedArrayList, container::OrderedLinkedList, container::OrderedList, container::Queue, container::QueueImpl, container::SortedArrayList, container::SortedLinkedList, container::SortedList, container::Stack, and container::StackImpl.

00079                                                   {
00080    return os << typeInfo()->typeName << " count(" << count << ')';
00081 }

Here is the call graph for this function:

void container::Container::setCount ( int  c  )  [protected]

Reimplemented in container::OrderedList, container::Queue, container::SortedList, and container::Stack.

00065                               {
00066    count = c;
00067 }

Here is the caller graph for this function:

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

Reimplemented in container::ArrayList, container::LinkedList, container::List, container::OrderedArrayList, container::OrderedLinkedList, container::OrderedList, container::Queue, container::QueueImpl, container::SortedArrayList, container::SortedLinkedList, container::SortedList, container::Stack, and container::StackImpl.

00083                                             {
00084    return TYPE_INFO;
00085 }

Here is the caller graph for this function:


Member Data Documentation

Number of Entity objects in this Container.

Access to modify this variable is should be controlled by an abstract base class where possible. Any method that modifies count should be implemented by the abstract class. For example, append(Entity) is implemented by OrderedList. No base class of OrderedList should override append(Entity*) or any other method that modifies count. Instead, methods like append(Entity*) are written as templates (in the OO sense, not the C++ template mechanism) and an "_impl" version is supplied for a derived class to override, e.g., append_impl(Entity*) which does the actual work of adding an item to the Container.

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


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

Generated on Tue Jun 16 23:12:58 2009 by  doxygen 1.5.9