#include <container.h>
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 Info * | typeInfo () const |
Return the instance of Object::Info that describes the class of this object. | |
virtual Object * | clone (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. |
container::Container::Container | ( | ) | [protected] |
container::Container::Container | ( | const Container & | orig | ) | [protected] |
virtual Object* container::Container::clone | ( | bool | deepCopy = false |
) | const [pure virtual] |
A polymorphic copy constructor.
Implements container::Object.
Implemented in container::ArrayList, container::List, container::OrderedArrayList, container::OrderedLinkedList, container::OrderedList, container::Queue, container::QueueImpl, container::SortedArrayList, container::SortedLinkedList, container::SortedList, container::Stack, and container::StackImpl.
void container::Container::decCount | ( | ) | [protected] |
Reimplemented in container::OrderedList, container::Queue, container::SortedList, and container::Stack.
00073 { 00074 count--; 00075 }
int container::Container::getCount | ( | ) | const |
void container::Container::incCount | ( | ) | [protected] |
Reimplemented in container::OrderedList, container::Queue, container::SortedList, and container::Stack.
00069 { 00070 count++; 00071 }
bool container::Container::isEmpty | ( | ) | const |
virtual int container::Container::purgeContents | ( | ) | [pure virtual] |
Empty the contents of the container, deleting all Entities.
This method is used by the destructor.
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.
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.
void container::Container::setCount | ( | int | c | ) | [protected] |
Reimplemented in container::OrderedList, container::Queue, container::SortedList, and container::Stack.
00065 { 00066 count = c; 00067 }
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 }
int container::Container::count [private] |
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] |
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.