#include <stackimpl.h>
Public Member Functions | |
StackImpl (const StackImpl &orig) | |
virtual | ~StackImpl () |
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 |
A polymorphic copy constructor. | |
Static Public Member Functions | |
static Stack * | factoryLinkedComposition () |
Constructs an StackImpl with an underlying OrderedLinkedList. | |
static Stack * | factoryArrayComposition () |
Constructs a StackImpl with an underlying OrderedArrayList. | |
Static Public Attributes | |
static const Info *const | TYPE_INFO |
Protected Member Functions | |
virtual void | push_impl (Entity *entity) |
Called by a template method. | |
virtual Entity * | pop_impl () |
Called by a template method. | |
Private Member Functions | |
StackImpl (OrderedList *list) | |
Private Attributes | |
OrderedList *const | list |
container::StackImpl::StackImpl | ( | OrderedList * | list | ) | [private] |
container::StackImpl::~StackImpl | ( | ) | [virtual] |
Object * container::StackImpl::clone | ( | bool | deepCopy = false |
) | const [virtual] |
Stack * container::StackImpl::factoryArrayComposition | ( | ) | [static] |
Constructs a StackImpl with an underlying OrderedArrayList.
00078 { 00079 return new StackImpl(new OrderedArrayList()); 00080 }
Stack * container::StackImpl::factoryLinkedComposition | ( | ) | [static] |
Constructs an StackImpl with an underlying OrderedLinkedList.
00074 { 00075 return new StackImpl(new OrderedLinkedList()); 00076 }
Entity * container::StackImpl::pop_impl | ( | ) | [protected, virtual] |
Called by a template method.
Implements container::Stack.
00064 { 00065 if (list->toLast()) { 00066 return list->extractCurrentEntity(); 00067 } else { 00068 return NULL; 00069 } 00070 }
void container::StackImpl::push_impl | ( | Entity * | entity | ) | [protected, virtual] |
Called by a template method.
Implements container::Stack.
00060 { 00061 list->append(entity); 00062 }
ostream & container::StackImpl::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::Stack.
00084 { 00085 00086 this->Stack::renderState(os); 00087 os << " composed with an " << list->typeInfo()->typeName << " contents{"; 00088 00089 int i = 0; 00090 for (list->toTail(); list->toPrev(); i++) { 00091 os << std::endl << " [" << i << ']' << list->currentEntity(); 00092 if (list->getCount() > 1) { 00093 if (list->isFirst()) { 00094 os << " <--BOTTOM"; 00095 } else if (list->isLast()) { 00096 os << " <--TOP"; 00097 } 00098 } 00099 } 00100 return os << "}"; 00101 }
const Object::Info * container::StackImpl::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::Stack.
00103 { 00104 return TYPE_INFO; 00105 }
OrderedList* const container::StackImpl::list [private] |
const Object::Info *const container::StackImpl::TYPE_INFO [static] |