30 #ifndef PTLIB_CONTAIN_H
31 #define PTLIB_CONTAIN_H
109 PINDEX initialSize = 0
148 virtual PINDEX
GetSize()
const;
340 #define PCONTAINERINFO(cls, par) \
341 PCLASSINFO(cls, par) \
343 cls(const cls & c) : par(c) { CopyContents(c); } \
344 cls & operator=(const cls & c) \
345 { AssignContents(c); return *this; } \
346 virtual ~cls() { Destruct(); } \
347 virtual PBoolean MakeUnique() \
348 { if(par::MakeUnique())return true; CloneContents(this);return false; } \
350 cls(int dummy, const cls * c) : par(dummy, c) { CloneContents(c); } \
351 virtual void DestroyContents(); \
352 void CloneContents(const cls * c); \
353 void CopyContents(const cls & c); \
354 virtual void AssignContents(const PContainer & c) \
355 { par::AssignContents(c); CopyContents((const cls &)c); }
402 PINDEX initialSize = 0
631 #include <ptlib/contain.inl>
635 #endif // PTLIB_CONTAIN_H
virtual PBoolean IsEmpty() const
Determine if the container is empty.
virtual PObject * GetAt(PINDEX index) const =0
Get the object at the specified ordinal position.
void CopyContents(const PContainer &c)
Copy the container contents.
virtual PBoolean MakeUnique()
Make this instance to be the one and only reference to the container contents.
virtual PINDEX Insert(const PObject &before, PObject *obj)=0
Insert a new object immediately before the specified object.
void Destruct()
Internal function called from container destructors.
atomic< uint32_t > count
Definition: contain.h:66
virtual PBoolean Remove(const PObject *obj)=0
Remove the object from the collection.
PINLINE void AllowDeleteObjects(PBoolean yes=true)
Allow or disallow the deletion of the objects contained in the collection.
virtual PINDEX InsertAt(PINDEX index, PObject *obj)=0
Insert a new object at the specified ordinal index.
#define PINLINE
Definition: object.h:194
virtual PINDEX Append(PObject *obj)=0
Append a new object to the collection.
PContainer & operator=(const PContainer &cont)
Assign one container reference to another.
virtual PObject * RemoveAt(PINDEX index)=0
Remove the object at the specified ordinal index from the collection.
virtual PINDEX GetValuesIndex(const PObject &obj) const =0
Search the collection for the specified value of the object.
virtual void RemoveAll()
Remove all of the elements in the collection.
PINDEX size
Definition: contain.h:65
virtual void AssignContents(const PContainer &c)
Copy the container contents.
PBoolean IsUnique() const
Determine if container is unique reference.
virtual void PrintOn(ostream &strm) const
Print the collection on the stream.
virtual PBoolean SetSize(PINDEX newSize)=0
Set the new current size of the container.
virtual void DestroyContents()=0
Destroy the container contents.
PContainer(PINDEX initialSize=0)
Create a new unique container.
virtual PINDEX GetSize() const
Get the current size of the container.
bool constObject
Definition: contain.h:68
bool PBoolean
Definition: object.h:174
bool deleteObjects
Definition: contain.h:67
virtual void DestroyReference()
Destroy the PContainerReference instance.
virtual ~PContainer()
Destroy the container class.
Definition: contain.h:135
Abstract class to embody the base functionality of a container.
Definition: contain.h:99
__inline bool empty() const
Definition: contain.h:184
virtual PBoolean SetAt(PINDEX index, PObject *val)=0
Set the object at the specified ordinal position to the new value.
virtual PINDEX GetObjectsIndex(const PObject *obj) const =0
Search the collection for the specific instance of the object.
__inline PContainerReference(PINDEX initialSize, bool isConst=false)
Definition: contain.h:49
PBoolean SetMinSize(PINDEX minSize)
Set the minimum size of container.
void CloneContents(const PContainer *src)
Create a duplicate of the container contents.
PCollection(PINDEX initialSize=0)
Create a new collection.
PDECLARE_POOL_ALLOCATOR(PContainerReference)
PContainerReference * reference
Definition: contain.h:288
__inline PContainerReference(const PContainerReference &ref)
Definition: contain.h:57
__inline size_t size() const
Definition: contain.h:149
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
A collection is a container that collects together descendents of the PObject class.
Definition: contain.h:392
void DisallowDeleteObjects()
Disallow the deletion of the objects contained in the collection.
__inline void clear()
Definition: contain.h:511