PSafeColl< Coll, Base > Class Template Reference

#include <safecoll.h>

Inheritance diagram for PSafeColl< Coll, Base >:

PSafeCollection PObject List of all members.

Public Member Functions

Operations
virtual PSafePtr< Base > Append (Base *obj, PSafetyMode mode=PSafeReference)
virtual PBoolean Remove (Base *obj)
virtual PBoolean RemoveAt (PINDEX idx)
virtual PSafePtr< Base > GetAt (PINDEX idx, PSafetyMode mode=PSafeReadWrite)
virtual PSafePtr< Base > FindWithLock (const Base &value, PSafetyMode mode=PSafeReadWrite)

Detailed Description

template<class Coll, class Base>
class PSafeColl< Coll, Base >

This class defines a thread-safe collection of objects.

This is part of a set of classes to solve the general problem of a collection (eg a PList or PDictionary) of objects that needs to be a made thread safe. Any thread can add, read, write or remove an object with both the object and the database of objects itself kept thread safe.

See the PSafeObject class for more details. Especially in regard to enumeration of collections.


Constructor & Destructor Documentation

template<class Coll, class Base>
PSafeColl< Coll, Base >::PSafeColl (  )  [inline]

Create a safe list collection wrapper around the real collection.

template<class Coll, class Base>
PSafeColl< Coll, Base >::PSafeColl (  )  [inline]

Create a safe list collection wrapper around the real collection.


Member Function Documentation

template<class Coll, class Base>
virtual PSafePtr<Base> PSafeColl< Coll, Base >::Append ( Base *  obj,
PSafetyMode  mode = PSafeReference 
) [inline, virtual]

Add an object to the collection. This uses the PCollection::Append() function to add the object to the collection, with full mutual exclusion locking on the collection.

Parameters:
obj  Object to add to safe collection.

template<class Coll, class Base>
virtual PBoolean PSafeColl< Coll, Base >::Remove ( Base *  obj  )  [inline, virtual]

Remove an object to the collection. This function removes the object from the collection itself, but does not actually delete the object. It simply moves the object to a list of objects to be garbage collected at a later time.

As for Append() full mutual exclusion locking on the collection itself is maintained.

Parameters:
obj  Object to remove from safe collection

template<class Coll, class Base>
virtual PBoolean PSafeColl< Coll, Base >::RemoveAt ( PINDEX  idx  )  [inline, virtual]

Remove an object to the collection. This function removes the object from the collection itself, but does not actually delete the object. It simply moves the object to a list of objects to be garbage collected at a later time.

As for Append() full mutual exclusion locking on the collection itself is maintained.

Parameters:
idx  Index to remove

template<class Coll, class Base>
virtual PSafePtr<Base> PSafeColl< Coll, Base >::GetAt ( PINDEX  idx,
PSafetyMode  mode = PSafeReadWrite 
) [inline, virtual]

Get the instance in the collection of the index. The returned safe pointer will increment the reference count on the PSafeObject and lock to the object in the mode specified. The lock will remain until the PSafePtr goes out of scope.

template<class Coll, class Base>
virtual PSafePtr<Base> PSafeColl< Coll, Base >::FindWithLock ( const Base &  value,
PSafetyMode  mode = PSafeReadWrite 
) [inline, virtual]

Find the instance in the collection of an object with the same value. The returned safe pointer will increment the reference count on the PSafeObject and lock to the object in the mode specified. The lock will remain until the PSafePtr goes out of scope.


The documentation for this class was generated from the following file:
Generated on Mon Feb 23 01:57:57 2009 for PTLib by  doxygen 1.5.1