Field3D
RefBase Class Referenceabstract

#include <RefCount.h>

Inheritance diagram for RefBase:
CubicGenericFieldInterp< Field_T > CubicMACFieldInterp< Data_T > FieldBase FieldIO FieldInterp< Data_T > FieldMapping FieldMappingIO File::Partition FileHDF5::Partition LinearGenericFieldInterp< Field_T > LinearMACFieldInterp< Data_T > LinearSparseFieldInterp< Data_T > ProceduralFieldLookup< Data_T >

Public Types

typedef boost::intrusive_ptr< RefBasePtr
 
typedef boost::weak_ptr< RefBaseWeakPtr
 

Public Member Functions

void ref () const
 Used by boost::intrusive_pointer.
 
size_t refcnt ()
 Used by boost::intrusive_pointer.
 
void unref () const
 Used by boost::intrusive_pointer.
 
WeakPtr weakPtr () const
 
Constructors, destructors, copying
 RefBase ()
 
 RefBase (const RefBase &)
 Copy constructor.
 
RefBaseoperator= (const RefBase &)
 Assignment operator.
 
virtual ~RefBase ()
 Destructor.
 

Private Attributes

boost::detail::atomic_count m_counter
 For boost intrusive pointer.
 
boost::shared_ptr< RefBasem_sharedPtr
 For use by the FieldCache only: The shared pointer lets us see if this object is still alive.
 

RTTI replacement

Note
A note on why the RTTI replacement is needed: RTTI calls fail once the object crosses the dso boundary. We revert to using simple string checks which is more expensive but at least works once the dso is used in Houdini, etc. Use field_dynamic_cast<> for any RefBase subclass instead of dynamic_cast<>.
virtual bool checkRTTI (const char *typenameStr)=0
 This function is only implemented by concrete classes and triggers the actual RTTI check through matchRTTI();.
 
bool matchRTTI (const char *typenameStr)
 Performs a check to see if the given typename string matches this class' This needs to be implemented in -all- subclasses, even abstract ones.
 
static const charstaticClassType ()
 

Detailed Description

Definition at line 106 of file RefCount.h.

Member Typedef Documentation

◆ Ptr

typedef boost::intrusive_ptr<RefBase> RefBase::Ptr

Definition at line 112 of file RefCount.h.

◆ WeakPtr

typedef boost::weak_ptr<RefBase> RefBase::WeakPtr

Definition at line 113 of file RefCount.h.

Constructor & Destructor Documentation

◆ RefBase() [1/2]

RefBase::RefBase ( )
inline

Definition at line 120 of file RefCount.h.

121 : m_counter(0),
122 m_sharedPtr(this, null_deleter())
123 { }
boost::shared_ptr< RefBase > m_sharedPtr
For use by the FieldCache only: The shared pointer lets us see if this object is still alive.
Definition RefCount.h:220
boost::detail::atomic_count m_counter
For boost intrusive pointer.
Definition RefCount.h:211
Used to let a shared pointer exist that doesn't delete anything. This is used by RefBase to hold a sh...
Definition RefCount.h:99

◆ RefBase() [2/2]

RefBase::RefBase ( const RefBase & )
inline

Copy constructor.

Note
The null_deleter ensures we never try to actually delete this object using the shared pointer.

Definition at line 128 of file RefCount.h.

129 : m_counter(0),
130 m_sharedPtr(this, null_deleter())
131 { }

◆ ~RefBase()

virtual RefBase::~RefBase ( )
inlinevirtual

Destructor.

Definition at line 138 of file RefCount.h.

139 {}

Member Function Documentation

◆ operator=()

RefBase & RefBase::operator= ( const RefBase & )
inline

Assignment operator.

Definition at line 134 of file RefCount.h.

135 { return *this; }

◆ refcnt()

size_t RefBase::refcnt ( )
inline

Used by boost::intrusive_pointer.

Definition at line 146 of file RefCount.h.

147 { return m_counter; }

◆ ref()

void RefBase::ref ( ) const
inline

Used by boost::intrusive_pointer.

Definition at line 150 of file RefCount.h.

151 {
152#ifndef FIELD3D_USE_ATOMIC_COUNT
153 boost::mutex::scoped_lock lock(m_refMutex);
154#endif
155 ++m_counter;
156 }
#define FIELD3D_MTX_T
Definition StdMathLib.h:99

References FIELD3D_MTX_T.

◆ unref()

void RefBase::unref ( ) const
inline

Used by boost::intrusive_pointer.

Definition at line 159 of file RefCount.h.

160 {
161#ifndef FIELD3D_USE_ATOMIC_COUNT
162 boost::mutex::scoped_lock lock(m_refMutex);
163#endif
164 --m_counter;
165 // since we use intrusive_pointer no need
166 // to delete the object ourselves.
167 }

References FIELD3D_MTX_T.

◆ weakPtr()

WeakPtr RefBase::weakPtr ( ) const
inline

Definition at line 171 of file RefCount.h.

172 { return m_sharedPtr; }

◆ checkRTTI()

virtual bool RefBase::checkRTTI ( const char * typenameStr)
pure virtual

This function is only implemented by concrete classes and triggers the actual RTTI check through matchRTTI();.

◆ matchRTTI()

bool RefBase::matchRTTI ( const char * typenameStr)
inline

Performs a check to see if the given typename string matches this class' This needs to be implemented in -all- subclasses, even abstract ones.

Definition at line 193 of file RefCount.h.

194 {
196 return true;
197 return false;
198 }
static const char * staticClassType()
Definition RefCount.h:200

References FIELD3D_MTX_T.

◆ staticClassType()

static const char * RefBase::staticClassType ( )
inlinestatic

Definition at line 200 of file RefCount.h.

201 {
202 return "RefBase";
203 }

Member Data Documentation

◆ m_counter

boost::detail::atomic_count RefBase::m_counter
mutableprivate

For boost intrusive pointer.

Definition at line 211 of file RefCount.h.

◆ m_sharedPtr

boost::shared_ptr<RefBase> RefBase::m_sharedPtr
private

For use by the FieldCache only: The shared pointer lets us see if this object is still alive.

Definition at line 220 of file RefCount.h.


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