sptr Class Template Reference

#include <support/Atom.h>

List of all members.


Detailed Description

template<class TYPE>
class sptr< TYPE >

Smart-pointer template that maintains a strong reference on a reference counted class.

Can be used with SAtom, SLightAtom, SLimAtom, and SSharedBuffer.

For the most part a sptr<T> looks and feels like a raw C++ pointer. However, currently sptr<> does not have a boolean conversion operator, so to check whether a sptr is NULL you will need to write code like this:

if (my_sptr == NULL) ...


Public Member Functions

TYPE * detach ()
 Clear (set to NULL) and return the raw pointer of this object.
TYPE * edit (size_t size)
 Version of edit() that allows you to change the size of the shared buffer.
TYPE * edit ()
 Retrieve edit access to the object.
bool is_null () const
 Return true if ptr() is NULL.
TYPE & operator * () const
 Dereference pointer.
TYPE * operator-> () const
 Member dereference.
template<>
sptr< SSharedBuffer > & operator= (SSharedBuffer *p)
template<class NEWTYPE>
sptr< TYPE > & operator= (const sptr< NEWTYPE > &p)
 Assignment from a strong pointer to another type of SAtom subclass (type conversion).
sptr< TYPE > & operator= (const sptr< TYPE > &p)
 Assignment from another sptr.
sptr< TYPE > & operator= (TYPE *p)
 Assignment from a raw pointer.
TYPE * ptr () const
 Return the raw pointer of this object.
template<>
 sptr (SSharedBuffer *p)
template<class NEWTYPE>
 sptr (const sptr< NEWTYPE > &p)
 Initialization from a strong pointer to another type of SAtom subclass (type conversion).
 sptr (const sptr< TYPE > &p)
 Initialize from another sptr.
 sptr (TYPE *p)
 Initialize from a raw pointer.
 sptr ()
 Initialize to NULL pointer.
 ~sptr ()
 Release strong reference on object.

Friends

class wptr< TYPE >


Constructor & Destructor Documentation

sptr  )  [inline]
 

Initialize to NULL pointer.

sptr TYPE *  p  )  [inline]
 

Initialize from a raw pointer.

sptr const sptr< TYPE > &  p  )  [inline]
 

Initialize from another sptr.

sptr const sptr< NEWTYPE > &  p  )  [inline]
 

Initialization from a strong pointer to another type of SAtom subclass (type conversion).

~sptr  )  [inline]
 

Release strong reference on object.

sptr SSharedBuffer p  )  [inline]
 


Member Function Documentation

TYPE * detach  )  [inline]
 

Clear (set to NULL) and return the raw pointer of this object.

You now own its strong reference and must manually call DecStrong().

TYPE * edit size_t  size  )  [inline]
 

Version of edit() that allows you to change the size of the shared buffer.

TYPE * edit  )  [inline]
 

Retrieve edit access to the object.

Use this with SSharedBuffer objects to request edit access to the buffer. If the buffer needs to be copied, the sptr<> will be updated to point to the new buffer. Returns a raw pointer to the buffer that you can modify.

bool is_null  )  const [inline]
 

Return true if ptr() is NULL.

Note:
It is preferred to just compare against NULL, that is:
if (my_atom == NULL) ...

TYPE & operator *  )  const [inline]
 

Dereference pointer.

TYPE * operator->  )  const [inline]
 

Member dereference.

sptr< SSharedBuffer > & operator= SSharedBuffer p  )  [inline]
 

sptr< TYPE > & operator= const sptr< NEWTYPE > &  p  )  [inline]
 

Assignment from a strong pointer to another type of SAtom subclass (type conversion).

sptr< TYPE > & operator= const sptr< TYPE > &  p  )  [inline]
 

Assignment from another sptr.

sptr< TYPE > & operator= TYPE *  p  )  [inline]
 

Assignment from a raw pointer.

TYPE * ptr  )  const [inline]
 

Return the raw pointer of this object.

Keeps the object and leaves its reference count as-is. You normally don't need to use this, and instead can use the -> and * operators.


Friends And Related Function Documentation

friend class wptr< TYPE > [friend]
 


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