Nebula
Loading...
Searching...
No Matches
Threading::ObjectRef Class Reference

#include <objectref.h>

Detailed Description

A thread-safe reference to a shared object.

Object refs are used with the messaging system to reference opaque objects created and manipulated in other threads. ObjectRef objects must be created on the heap (thus they are ref-counted) because the "client-side" owner-object may be discarded before the target object in the other thread is destroyed.

Inherits Core::RefCounted.

Public Member Functions

 ObjectRef ()
 constructor
virtual ~ObjectRef ()
 destructor
bool IsValid () const
 return true if the ObjectRef points to a valid object
template<class TYPE>
void Validate (TYPE *obj)
 validate the ref with a pointer to a target object (must be RefCounted)
void Invalidate ()
 invalidate the ref
template<class TYPE>
TYPE * Ref () const
 get pointer to object
Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
int GetRefCount () const
 get the current refcount
void AddRef ()
 increment refcount by one
void Release ()
 decrement refcount and destroy object if refcount is zero
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
const Util::StringGetClassName () const
 get the class name
Util::FourCC GetClassFourCC () const
 get the class FourCC code

Private Member Functions

 __DeclareClass (ObjectRef)

Private Attributes

Core::RefCounted *volatile ref

Additional Inherited Members

Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)

Constructor & Destructor Documentation

◆ ObjectRef()

Threading::ObjectRef::ObjectRef ( )

constructor

◆ ~ObjectRef()

Threading::ObjectRef::~ObjectRef ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

Threading::ObjectRef::__DeclareClass ( ObjectRef )
private

◆ Invalidate()

void Threading::ObjectRef::Invalidate ( )
inline

invalidate the ref

◆ IsValid()

bool Threading::ObjectRef::IsValid ( ) const
inline

return true if the ObjectRef points to a valid object

◆ Ref()

template<class TYPE>
TYPE * Threading::ObjectRef::Ref ( ) const
inline

get pointer to object

◆ Validate()

template<class TYPE>
void Threading::ObjectRef::Validate ( TYPE * obj)
inline

validate the ref with a pointer to a target object (must be RefCounted)

Member Data Documentation

◆ ref

Core::RefCounted* volatile Threading::ObjectRef::ref
private

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