Field3D
RefCount.h File Reference

Contains base class for reference counting with Mutex. More...

#include <boost/intrusive_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/detail/atomic_count.hpp>
#include <string.h>
#include "Traits.h"
#include "ns.h"

Go to the source code of this file.

Classes

struct  null_deleter
 Used to let a shared pointer exist that doesn't delete anything. This is used by RefBase to hold a shared pointer to *this without actually deleting twice when the object goes out of scope. More...
 
class  RefBase
 

Macros

#define DEFINE_CHECK_RTTI_CALL
 
#define DEFINE_FIELD_RTTI_ABSTRACT_CLASS    DEFINE_MATCH_RTTI_CALL \
 
#define DEFINE_FIELD_RTTI_CONCRETE_CLASS
 
#define DEFINE_MATCH_RTTI_CALL
 
#define FIELD3D_USE_ATOMIC_COUNT
 
#define FIELD_DYNAMIC_CAST   field_dynamic_cast
 

Functions

template<class Field_T >
Field_T::Ptr field_dynamic_cast (RefBase::Ptr field)
 Dynamic cast that uses string-comparison in order to be safe even after an object crosses a shared library boundary.
 
void intrusive_ptr_add_ref (RefBase *r)
 
void intrusive_ptr_release (RefBase *r)
 

Detailed Description

Contains base class for reference counting with Mutex.

Definition in file RefCount.h.

Macro Definition Documentation

◆ FIELD3D_USE_ATOMIC_COUNT

#define FIELD3D_USE_ATOMIC_COUNT

Definition at line 47 of file RefCount.h.

◆ DEFINE_CHECK_RTTI_CALL

#define DEFINE_CHECK_RTTI_CALL
Value:
virtual bool checkRTTI(const char *typenameStr) \
{ return matchRTTI(typenameStr); } \

Definition at line 71 of file RefCount.h.

71#define DEFINE_CHECK_RTTI_CALL \
72 virtual bool checkRTTI(const char *typenameStr) \
73 { return matchRTTI(typenameStr); } \
74

◆ DEFINE_MATCH_RTTI_CALL

#define DEFINE_MATCH_RTTI_CALL
Value:
bool matchRTTI(const char *typenameStr) \
{ \
if (strcmp(typenameStr,staticClassType()) == 0) { \
return true; \
} \
return base::matchRTTI(typenameStr); \
} \

Definition at line 75 of file RefCount.h.

75#define DEFINE_MATCH_RTTI_CALL \
76 bool matchRTTI(const char *typenameStr) \
77 { \
78 if (strcmp(typenameStr,staticClassType()) == 0) { \
79 return true; \
80 } \
81 return base::matchRTTI(typenameStr); \
82 } \
83

◆ DEFINE_FIELD_RTTI_CONCRETE_CLASS

#define DEFINE_FIELD_RTTI_CONCRETE_CLASS
Value:
DEFINE_CHECK_RTTI_CALL \
DEFINE_MATCH_RTTI_CALL \

Definition at line 84 of file RefCount.h.

84#define DEFINE_FIELD_RTTI_CONCRETE_CLASS \
85 DEFINE_CHECK_RTTI_CALL \
86 DEFINE_MATCH_RTTI_CALL \
87

◆ DEFINE_FIELD_RTTI_ABSTRACT_CLASS

#define DEFINE_FIELD_RTTI_ABSTRACT_CLASS    DEFINE_MATCH_RTTI_CALL \

Definition at line 88 of file RefCount.h.

88#define DEFINE_FIELD_RTTI_ABSTRACT_CLASS \
89 DEFINE_MATCH_RTTI_CALL \
90

◆ FIELD_DYNAMIC_CAST

Function Documentation

◆ intrusive_ptr_add_ref()

void intrusive_ptr_add_ref ( RefBase * r)
inline

Definition at line 229 of file RefCount.h.

230{
231 r->ref();
232}
void ref() const
Used by boost::intrusive_pointer.
Definition RefCount.h:150

References RefBase::ref().

◆ intrusive_ptr_release()

void intrusive_ptr_release ( RefBase * r)
inline
Todo
Communicate with the FieldCache to prevent any cache updates from happening while this releases its count.

Definition at line 239 of file RefCount.h.

240{
241 r->unref();
242
243 if (r->refcnt() == 0)
244 delete r;
245}
size_t refcnt()
Used by boost::intrusive_pointer.
Definition RefCount.h:146
void unref() const
Used by boost::intrusive_pointer.
Definition RefCount.h:159

References RefBase::refcnt(), and RefBase::unref().