RefBase Class Referenceabstract

`#include <RefCount.h>`

Inheritance diagram for RefBase:

## Public Types

typedef boost::intrusive_ptr< RefBase > | Ptr
typedef boost::weak_ptr< RefBase > | WeakPtr

## 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.
RefBase & | operator= (const RefBase &)
| Assignment operator.
virtual | ~RefBase ()
| Destructor.

## Private Attributes

boost::detail::atomic_count | m_counter
| For boost intrusive pointer.
boost::shared_ptr< RefBase > | m_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 char * | staticClassType ()

## 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.

: m_counter(0),
m_sharedPtr(this, null_deleter())
{ }
RefBase::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
RefBase::m_counter
boost::detail::atomic_count m_counter
For boost intrusive pointer.
Definition RefCount.h:211

References m_counter, and m_sharedPtr.

Referenced by FieldBase::FieldBase(), FieldBase::FieldBase(), FieldIO::FieldIO(), FieldMapping::FieldMapping(), FieldMapping::FieldMapping(), FieldMappingIO::FieldMappingIO(), operator=(), File::Partition::Partition(), FileHDF5::Partition::Partition(), and RefBase().

## 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.

: m_counter(0),
m_sharedPtr(this, null_deleter())
{ }

References m_counter, m_sharedPtr, and RefBase().

## ~RefBase()

virtual RefBase::~RefBase | ( |  | ) |

inline virtual

Destructor.

Definition at line 138 of file RefCount.h.

{}

## Member Function Documentation

## operator=()

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

inline

Assignment operator.

Definition at line 134 of file RefCount.h.

{ return *this; }

References RefBase().

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

## refcnt()

size_t RefBase::refcnt | ( |  | ) |

inline

Used by boost::intrusive_pointer.

Definition at line 146 of file RefCount.h.

{ return m_counter; }

References m_counter.

Referenced by intrusive_ptr_release().

## ref()

void RefBase::ref | ( |  | ) | const

inline

Used by boost::intrusive_pointer.

Definition at line 150 of file RefCount.h.

{
#ifndef FIELD3D_USE_ATOMIC_COUNT
boost::mutex::scoped_lock lock(m_refMutex);
#endif
++m_counter;
}

References m_counter.

Referenced by intrusive_ptr_add_ref().

## unref()

void RefBase::unref | ( |  | ) | const

inline

Used by boost::intrusive_pointer.

Definition at line 159 of file RefCount.h.

{
#ifndef FIELD3D_USE_ATOMIC_COUNT
boost::mutex::scoped_lock lock(m_refMutex);
#endif
--m_counter;
// since we use intrusive_pointer no need
// to delete the object ourselves.
}

References m_counter.

Referenced by intrusive_ptr_release().

## weakPtr()

WeakPtr RefBase::weakPtr | ( |  | ) | const

inline

Definition at line 171 of file RefCount.h.

{ return m_sharedPtr; }

References 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.

{
if (strcmp(staticClassType(), typenameStr) == 0)
return true;
return false;
}
RefBase::staticClassType
static const char * staticClassType()
Definition RefCount.h:200

References staticClassType().

## staticClassType()

const char * RefBase::staticClassType | ( |  | ) |

inline static

Definition at line 200 of file RefCount.h.

{
return "RefBase";
}

Referenced by matchRTTI().

## Member Data Documentation

## m_counter

boost::detail::atomic_count RefBase::m_counter

mutable private

For boost intrusive pointer.

Definition at line 211 of file RefCount.h.

Referenced by ref(), RefBase(), RefBase(), refcnt(), and unref().

## 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.

Referenced by RefBase(), RefBase(), and weakPtr().

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

- export/RefCount.h