PSafeDictionaryBase< Coll, Key, Base > Class Template Reference

This class defines a thread-safe dictionary of objects. More...

#include <safecoll.h>

Inheritance diagram for PSafeDictionaryBase< Coll, Key, Base >:

PSafeCollection PObject List of all members.

Public Member Functions

Construction
 PSafeDictionaryBase ()
 Create a safe dictionary wrapper around the real collection.
 PSafeDictionaryBase (const PSafeDictionaryBase &other)
 Copy constructor for safe collection.
PSafeDictionaryBaseoperator= (const PSafeDictionaryBase &other)
 Assign one safe collection to another.
Operations
virtual void SetAt (const Key &key, Base *obj)
 Add an object to the collection.
virtual PBoolean RemoveAt (const Key &key)
 Remove an object to the collection.
virtual PBoolean Contains (const Key &key)
 Determine of the dictionary contains an entry for the key.
virtual PSafePtr< Base > GetAt (PINDEX idx, PSafetyMode mode=PSafeReadWrite)
 Get the instance in the collection of the index.
virtual PSafePtr< Base > FindWithLock (const Key &key, PSafetyMode mode=PSafeReadWrite)
 Find the instance in the collection of an object with the same value.

Detailed Description

template<class Coll, class Key, class Base>
class PSafeDictionaryBase< Coll, Key, Base >

This class defines a thread-safe dictionary 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 Key, class Base>
PSafeDictionaryBase< Coll, Key, Base >::PSafeDictionaryBase (  )  [inline]

Create a safe dictionary wrapper around the real collection.

template<class Coll, class Key, class Base>
PSafeDictionaryBase< Coll, Key, Base >::PSafeDictionaryBase ( const PSafeDictionaryBase< Coll, Key, Base > &  other  )  [inline]

Copy constructor for safe collection.

Note the left hand side will always have DisallowDeleteObjects() set.


Member Function Documentation

template<class Coll, class Key, class Base>
virtual PBoolean PSafeDictionaryBase< Coll, Key, Base >::Contains ( const Key &  key  )  [inline, virtual]

Determine of the dictionary contains an entry for the key.

template<class Coll, class Key, class Base>
virtual PSafePtr<Base> PSafeDictionaryBase< Coll, Key, Base >::FindWithLock ( const Key &  key,
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.

template<class Coll, class Key, class Base>
virtual PSafePtr<Base> PSafeDictionaryBase< Coll, Key, 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 Key, class Base>
PSafeDictionaryBase& PSafeDictionaryBase< Coll, Key, Base >::operator= ( const PSafeDictionaryBase< Coll, Key, Base > &  other  )  [inline]

Assign one safe collection to another.

Note the left hand side will always have DisallowDeleteObjects() set.

template<class Coll, class Key, class Base>
virtual PBoolean PSafeDictionaryBase< Coll, Key, Base >::RemoveAt ( const Key &  key  )  [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:
key  Key to fund object to delete

template<class Coll, class Key, class Base>
virtual void PSafeDictionaryBase< Coll, Key, Base >::SetAt ( const Key &  key,
Base *  obj 
) [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.


The documentation for this class was generated from the following file:
Generated on Fri Oct 14 01:44:12 2011 for PTLib by  doxygen 1.4.7