#include <queueimpl.h>
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 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 Queue * | factoryLinkedComposition () |
Constructs an QueueImpl with an underlying OrderedLinkedList. | |
static Queue * | factoryArrayComposition () |
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 Entity * | dequeue_impl () |
Called by a template method. | |
Private Member Functions | |
QueueImpl (OrderedList *list) | |
Private Attributes | |
OrderedList *const | list |
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.
container::QueueImpl::QueueImpl | ( | OrderedList * | list | ) | [private] |
container::QueueImpl::QueueImpl | ( | const QueueImpl & | orig | ) |
container::QueueImpl::QueueImpl | ( | const QueueImpl & | orig, | |
bool | deepCopy | |||
) |
container::QueueImpl::~QueueImpl | ( | ) | [virtual] |
Object * container::QueueImpl::clone | ( | bool | deepCopy = false |
) | const [virtual] |
A polymorphic copy constructor.
Implements container::Queue.
00111 { 00112 return new QueueImpl(*this, deepCopy); 00113 }
Entity * container::QueueImpl::dequeue_impl | ( | ) | [protected, virtual] |
Called by a template method.
Implements container::Queue.
00078 { 00079 if (list->toFirst()) { 00080 return list->extractCurrentEntity(); 00081 } else { 00082 return NULL; 00083 } 00084 }
void container::QueueImpl::enqueue_impl | ( | Entity * | entity | ) | [protected, virtual] |
Called by a template method.
Implements container::Queue.
00074 { 00075 list->append(entity); 00076 }
Queue * container::QueueImpl::factoryArrayComposition | ( | ) | [static] |
Constructs a QueueImpl with an underlying OrderedArrayList.
00068 { 00069 return new QueueImpl(new OrderedArrayList()); 00070 }
Queue * container::QueueImpl::factoryLinkedComposition | ( | ) | [static] |
Constructs an QueueImpl with an underlying OrderedLinkedList.
00064 { 00065 return new QueueImpl(new OrderedLinkedList()); 00066 }
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.
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 }
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 }
OrderedList* const container::QueueImpl::list [private] |
const Object::Info *const container::QueueImpl::TYPE_INFO [static] |