Field3D
RefBase Class Referenceabstract

#include <RefCount.h>

Inheritance diagram for RefBase:
CubicGenericFieldInterp< Field_T > CubicMACFieldInterp< Data_T > FieldBase FieldInterp< Data_T > FieldIO FieldMapping FieldMappingIO File::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. More...
 
size_t refcnt ()
 Used by boost::intrusive_pointer. More...
 
void unref () const
 Used by boost::intrusive_pointer. More...
 
WeakPtr weakPtr () const
 
Constructors, destructors, copying
 RefBase ()
 
 RefBase (const RefBase &)
 Copy constructor. More...
 
RefBaseoperator= (const RefBase &)
 Assignment operator. More...
 
virtual ~RefBase ()
 Destructor. More...
 

Private Attributes

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

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();. More...
 
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. More...
 
static const char * staticClassType ()
 

Detailed Description

Definition at line 106 of file RefCount.h.

Member Typedef Documentation

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

Definition at line 112 of file RefCount.h.

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

Definition at line 113 of file RefCount.h.

Constructor & Destructor Documentation

RefBase::RefBase ( )
inline

Definition at line 120 of file RefCount.h.

121  : m_counter(0),
122  m_sharedPtr(this, null_deleter())
123  { }
boost::detail::atomic_count m_counter
For boost intrusive pointer.
Definition: RefCount.h:211
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
Used to let a shared pointer exist that doesn&#39;t delete anything. This is used by RefBase to hold a sh...
Definition: RefCount.h:98
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  { }
boost::detail::atomic_count m_counter
For boost intrusive pointer.
Definition: RefCount.h:211
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
Used to let a shared pointer exist that doesn&#39;t delete anything. This is used by RefBase to hold a sh...
Definition: RefCount.h:98
virtual RefBase::~RefBase ( )
inlinevirtual

Destructor.

Definition at line 138 of file RefCount.h.

139  {}

Member Function Documentation

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

Assignment operator.

Definition at line 134 of file RefCount.h.

Referenced by MIPField< Field_T >::operator=(), SparseField< Data_T >::operator=(), and SparseField< Data_T >::staticClassType().

135  { return *this; }
size_t RefBase::refcnt ( )
inline

Used by boost::intrusive_pointer.

Definition at line 146 of file RefCount.h.

Referenced by intrusive_ptr_release().

147  { return m_counter; }
boost::detail::atomic_count m_counter
For boost intrusive pointer.
Definition: RefCount.h:211
void RefBase::ref ( ) const
inline

Used by boost::intrusive_pointer.

Definition at line 150 of file RefCount.h.

Referenced by intrusive_ptr_add_ref().

151  {
152 #ifndef FIELD3D_USE_ATOMIC_COUNT
153  boost::mutex::scoped_lock lock(m_refMutex);
154 #endif
155  ++m_counter;
156  }
boost::detail::atomic_count m_counter
For boost intrusive pointer.
Definition: RefCount.h:211
void RefBase::unref ( ) const
inline

Used by boost::intrusive_pointer.

Definition at line 159 of file RefCount.h.

Referenced by intrusive_ptr_release().

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  }
boost::detail::atomic_count m_counter
For boost intrusive pointer.
Definition: RefCount.h:211
WeakPtr RefBase::weakPtr ( ) const
inline

Definition at line 171 of file RefCount.h.

172  { return m_sharedPtr; }
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
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();.

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  {
195  if (strcmp(staticClassType(), typenameStr) == 0)
196  return true;
197  return false;
198  }
static const char * staticClassType()
Definition: RefCount.h:200
static const char* RefBase::staticClassType ( )
inlinestatic

Definition at line 200 of file RefCount.h.

201  {
202  return "RefBase";
203  }

Member Data Documentation

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

For boost intrusive pointer.

Definition at line 211 of file RefCount.h.

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: