Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

PSafePtr< T > Class Template Reference

#include <safecoll.h>

Inheritance diagram for PSafePtr< T >:

PSafePtrBase PObject

List of all members.


Detailed Description

template<class T>
class PSafePtr< T >

This class defines a thread-safe enumeration of object in a collection.

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.

There are two modes of safe pointer, one that is enumerating a collection and one that is independent of the collection that the safe object is in. There are some subtle semantics that must be observed in each of these two modes especially when switching from one to the other.

NOTE: the PSafePtr will allow safe and mutexed access to objects but is not thread safe itself! You should not share PSafePtr instances across threads. You can assign a PSafePtr to another instance across a thread boundary provided it is on a reference and no read only or read/write locks are present.

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

Definition at line 615 of file safecoll.h.


Comparison functions

virtual Comparison CompareObjectMemoryDirect (const PObject &obj) const
bool operator!= (const PObject &obj) const
bool operator< (const PObject &obj) const
bool operator<= (const PObject &obj) const
bool operator== (const PObject &obj) const
bool operator> (const PObject &obj) const
bool operator>= (const PObject &obj) const
enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }

Run Time Type functions

virtual const char * GetClass (unsigned=0) const
virtual BOOL InternalIsDescendant (const char *clsName) const
BOOL IsClass (const char *cls) const
static const char * Class ()

I/O functions

virtual void PrintOn (ostream &strm) const
virtual void ReadFrom (istream &strm)
ostream & operator<< (ostream &strm, const PObject &obj)
istream & operator>> (istream &strm, PObject &obj)

Public Member Functions

void Assign (PINDEX idx)
void Assign (PSafeObject *obj)
void Assign (const PSafeCollection &safeCollection)
void Assign (const PSafePtrBase &ptr)
Miscellaneous functions
virtual PObjectClone () const
virtual PINDEX HashFunction () const
Overrides from class PObject
Comparison Compare (const PObject &obj) const
Operations
const PSafeCollectionGetCollection () const
PSafetyMode GetSafetyMode () const
bool operator! () const
BOOL SetSafetyMode (PSafetyMode mode)
Operations
 operator T * () const
T & operator* () const
T * operator++ ()
T * operator++ (int)
T * operator-- ()
T * operator-- (int)
T * operator-> () const
Construction
PSafePtroperator= (PINDEX idx)
PSafePtroperator= (T *obj)
PSafePtroperator= (const PSafeCollection &safeCollection)
PSafePtroperator= (const PSafePtr &ptr)
 PSafePtr (const PSafePtr &ptr)
 PSafePtr (const PSafeCollection &safeCollection, PSafetyMode mode, PSafeObject *obj)
 PSafePtr (const PSafeCollection &safeCollection, PSafetyMode mode=PSafeReadWrite, PINDEX idx=0)
 PSafePtr (T *obj=NULL, PSafetyMode mode=PSafeReference)

Protected Types

enum  EnterSafetyModeOption { WithReference, AlreadyReferenced }
enum  ExitSafetyModeOption { WithDereference, NoDereference }

Protected Member Functions

BOOL EnterSafetyMode (EnterSafetyModeOption ref)
void ExitSafetyMode (ExitSafetyModeOption ref)
void Next ()
void Previous ()

Protected Attributes

const PSafeCollectioncollection
PSafeObjectcurrentObject
PSafetyMode lockMode

Private Member Functions

 PCLASSINFO (PSafePtr, PSafePtrBase)

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index