Atom.h File Reference


Detailed Description

Basic reference-counting classes, and smart pointer templates for working with them.

#include <support/SupportDefs.h>
#include <new>
#include <typeinfo>

Go to the source code of this file.

Classes

class  SAtom
 Base class for a reference-counted object. More...
struct  SAtom::weak_atom_ptr
 Represents a safe weak reference on an SAtom object. More...
class  SLightAtom
 A variation of SAtom that only supports strong reference counts. More...
class  SLimAtom
 A minimalistic variation of SAtom/SLightAtom that only supports strong reference counts. More...
class  sptr
 Smart-pointer template that maintains a strong reference on a reference counted class. More...
class  TypeConversion
 Compile-time check to see whether a type conversion is valid. More...
class  wptr
 Smart-pointer template that maintains a weak reference on an SAtom class. More...

Reference Counting Macros

These are macros for incremementing and decrementing reference counts, which use a special fast path on release builds. You would be much happier ignoring that these exist, and instead using the sptr<> and wptr<> smart pointers below.

#define B_ATTEMPT_INC_STRONG(atom, who)   atom->AttemptIncStrong(who)
#define B_ATTEMPT_INC_WEAK(atom, who)   atom->AttemptIncWeak(who)
#define B_DEC_STRONG(atom, who)   atom->DecStrong(who)
#define B_DEC_WEAK(atom, who)   atom->DecWeak(who)
#define B_FORCE_INC_STRONG(atom, who)   atom->ForceIncStrong(who)
#define B_INC_STRONG(atom, who)   atom->IncStrong(who)
#define B_INC_WEAK(atom, who)   atom->IncWeak(who)

Defines

#define COMPARE(op)
#define COMPARE_FRIEND(op)
#define COMPARE_FRIEND(op)

Enumerations

enum  {
  B_ATOM_REPORT_FORCE_LONG = 0x0001, B_ATOM_REPORT_FORCE_SHORT = 0x0002, B_ATOM_REPORT_FORCE_SUMMARY = 0x0003, B_ATOM_REPORT_FORCE_MASK = 0x000f,
  B_ATOM_REPORT_REMOVE_HEADER = 0x0010
}
 Flags for SAtom debugging reports. More...
enum  { B_ATOM_FIRST_STRONG = 0x0001 }
 Flags passed to SAtom::IncStrongAttempted(). More...

Functions

template<class NEWTYPE, class TYPE>
sptr< NEWTYPE > & sptr_reinterpret_cast (const sptr< TYPE > &v)
 Convenience to cast between sptr<> objects of different types.
template<class NEWTYPE, class TYPE>
wptr< NEWTYPE > & wptr_reinterpret_cast (const wptr< TYPE > &v)
 Convenience to cast between wptr<> objects of different types.


Define Documentation

#define B_ATTEMPT_INC_STRONG atom,
who   )     atom->AttemptIncStrong(who)
 

#define B_ATTEMPT_INC_WEAK atom,
who   )     atom->AttemptIncWeak(who)
 

#define B_DEC_STRONG atom,
who   )     atom->DecStrong(who)
 

#define B_DEC_WEAK atom,
who   )     atom->DecWeak(who)
 

#define B_FORCE_INC_STRONG atom,
who   )     atom->ForceIncStrong(who)
 

#define B_INC_STRONG atom,
who   )     atom->IncStrong(who)
 

#define B_INC_WEAK atom,
who   )     atom->IncWeak(who)
 

#define COMPARE op   ) 
 

Value:

template<class TYPE> inline                                                                     \
bool sptr<TYPE>::operator op (const TYPE* p2) const                                             \
    { return ptr() op p2; }                                                                     \
template<class TYPE> inline                                                                     \
bool sptr<TYPE>::operator op (const sptr<TYPE>& p2) const                                       \
    { return ptr() op p2.ptr(); }                                                               \
template<class TYPE> inline                                                                     \
bool sptr<TYPE>::operator op (const wptr<TYPE>& p2) const                                       \
    { return ptr() op p2.unsafe_ptr_access(); }                                                 \
template<class TYPE> inline                                                                     \
bool wptr<TYPE>::operator op (const TYPE* p2) const                                             \
    { return unsafe_ptr_access() op p2; }                                                       \
template<class TYPE> inline                                                                     \
bool wptr<TYPE>::operator op (const sptr<TYPE>& p2) const                                       \
    { return unsafe_ptr_access() op p2.ptr(); }                                                 \
template<class TYPE> inline                                                                     \
bool wptr<TYPE>::operator op (const wptr<TYPE>& p2) const                                       \
    { return unsafe_ptr_access() op p2.unsafe_ptr_access(); }                                   \

#define COMPARE_FRIEND op   ) 
 

Value:

bool operator op (const TYPE* p2) const;            \
            bool operator op (const sptr<TYPE>& p2) const;      \
            bool operator op (const wptr<TYPE>& p2) const;      \

#define COMPARE_FRIEND op   ) 
 

Value:

bool operator op (const TYPE* p2) const;            \
            bool operator op (const sptr<TYPE>& p2) const;      \
            bool operator op (const wptr<TYPE>& p2) const;      \


Function Documentation

sptr<NEWTYPE>& sptr_reinterpret_cast const sptr< TYPE > &  v  )  [inline]
 

Convenience to cast between sptr<> objects of different types.

wptr<NEWTYPE>& wptr_reinterpret_cast const wptr< TYPE > &  v  )  [inline]
 

Convenience to cast between wptr<> objects of different types.