Abstract class to embody the base functionality of acontainer .
![]() | Construction |
![]() | Common functions for containers |
![]() | PContainer ( int dummy, const PContainer * cont ) Constructor used in support of the Clone() function. |
![]() | DestroyContents () Destroy the container contents. |
![]() | AssignContents (const PContainer & c) Copy the container contents. |
![]() | CopyContents (const PContainer & c) Copy the container contents. |
![]() | CloneContents (const PContainer * src) Create a duplicate of the container contents. |
![]() | Destruct () Internal function called from container destructors. |
Run Time Type functions
Comparison functions
I/O functions
Miscellaneous functions
Abstract class to embody the base functionality of acontainer .Fundamentally, a container is an object that contains other objects. There are two main areas of support for tha that are provided by this class. The first is simply to keep a count of the number of things that the container contains. The current size is stored and accessed by members of this class. The setting of size is determined by the semantics of the descendent class and so is a pure function.
The second area of support is for reference integrity. When an instance of a container is copied to another instance, the two instance contain the same thing. There can therefore be multiple references to the same things. When one reference is destroyed this must not destroy the contained object as it may be referenced by another instance of a container class. To this end a reference count is provided by the PContainer class. This assures that the container only destroys the objects it contains when there are no more references to them.
In support of this, descendent classes must provide a DestroyContents() function. As the normal destructor cannot be used, this function will free the memory or unlock the resource the container is wrapping.
Note that the old contents of the container is dereferenced and if
it was unique, destroyed using the DestroyContents() function.
PContainer( const PContainer & cont )
PContainer& operator=( const PContainer & cont )
virtual PINLINE ~PContainer()
Note for some types of containers this does not do anything as they
inherently only contain one item. The function returns TRUE always and
the new value is ignored.
virtual BOOL SetSize( PINDEX newSize )
BOOL SetMinSize( PINDEX minSize )
virtual BOOL IsEmpty() const
BOOL IsUnique() const
virtual BOOL MakeUnique()
The dummy parameter is there to prevent the contructor from being invoked automatically by the compiler when a pointer is used by accident when a normal instance or reference was expected. The container would be silently cloned and the copy used instead of the container expected leading to unpredictable results.
For all descendent classes not immediately inheriting off the PContainer
itself, the implementation of DestroyContents() should always call its
ancestors function. This is especially relevent if many of the standard
container classes, such as arrays, are descended from as memory leaks
will occur.
No duplication of contents occurs, for instance if the container is an
array, the pointer to the array memory is copied, not the array memory
block itself. This function will get called by the base assignment operator.
No duplication of contents occurs, for instance if the container is an
array, the pointer to the array memory is copied, not the array memory
block itself. This function will get called once for every class in the heirarchy, so
the ancestor function should not be called.
This class will duplicate the contents completely, for instance if the
container is an array, the actual array memory is copied, not just the
pointer. If the container contains objects that descend from PObject,
they too should also be cloned and not simply copied. This function will get called once for every class in the heirarchy, so
the ancestor function should not be called.
virtual void DestroyContents()
virtual void AssignContents(const PContainer & c)
void CopyContents(const PContainer & c)
void CloneContents(const PContainer * src)
void Destruct()
Alphabetic index HTML hierarchy of classes or Java