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

Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions

PSafePtr< T > Class Template Reference

#include <safecoll.h>

Inheritance diagram for PSafePtr< T >:
Inheritance graph
[legend]
Collaboration diagram for PSafePtr< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

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

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)

Run Time Type functions

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

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 }

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)

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.


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

Generated by  Doxygen 1.6.0   Back to index