template<typename T> class ReferenceCountedObject< T >
This class implements reference counting. Any class that is properly derived from this class will get reference counted, provided that the library is configured with --enable-reference-counting and you are compiling with DEBUG defined. For example, the following is sufficient to define the class Foo as a reference counted class:
class Foo : public ReferenceCountedObject<Foo>
{
public:
Foo () {}
~Foo () {}
void bar ();
private:
};
If the library is configured with --disable-reference-counting or DEBUG is not defined then this class does nothing. All members are inlined and empty, so they should effectively disappear.
Author:
Benjamin S. Kirk, 2002-2007
Definition at line 68 of file reference_counted_object.h.
Member Typedef Documentation
typedef std::map<std::string, std::pair<unsigned int, unsigned int> > ReferenceCounter::Counts [protected, inherited]Data structure to log the information. The log is identified by the class name.
Definition at line 105 of file reference_counter.h.
Constructor & Destructor Documentation
template<typename T> ReferenceCountedObject< T >::ReferenceCountedObject () [inline, protected]Constructor. Protected so that you cannont instantiate a ReferenceCountedObject, only derive from it.
Definition at line 77 of file reference_counted_object.h.
std::string ReferenceCounter::get_info () [static, inherited]Gets a string containing the reference information.
Definition at line 45 of file reference_counter.C.
References ReferenceCounter::_counts, and Quality::name().
Referenced by ReferenceCounter::print_info().
{
#if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
std::ostringstream out;
out << '
<< ' ----------------------------------------------------------------------------
<< '| Reference count information |
<< ' ---------------------------------------------------------------------------- ;
for (Counts::iterator it = _counts.begin();
it != _counts.end(); ++it)
{
const std::string name(it->first);
const unsigned int creations = it->second.first;
const unsigned int destructions = it->second.second;
out << '| ' << name << ' reference count information:
<< '| Creations: ' << creations << '
<< '| Destructions: ' << destructions << ';
}
out << ' ---------------------------------------------------------------------------- ;
return out.str();
#else
return '';
#endif
}
void ReferenceCounter::increment_constructor_count (const std::string &name) [inline, protected, inherited]Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.
Definition at line 149 of file reference_counter.h.
References ReferenceCounter::_counts, Quality::name(), and Threads::spin_mtx.
Referenced by ReferenceCountedObject< Value >::ReferenceCountedObject().
void ReferenceCounter::increment_destructor_count (const std::string &name) [inline, protected, inherited]Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.
Definition at line 167 of file reference_counter.h.
References ReferenceCounter::_counts, Quality::name(), and Threads::spin_mtx.
Referenced by ReferenceCountedObject< Value >::~ReferenceCountedObject().
static unsigned int ReferenceCounter::n_objects () [inline, static, inherited]Prints the number of outstanding (created, but not yet destroyed) objects.
Definition at line 76 of file reference_counter.h.
References ReferenceCounter::_n_objects.
Referenced by System::read_serialized_blocked_dof_objects(), and System::write_serialized_blocked_dof_objects().
{ return _n_objects; }
void ReferenceCounter::print_info () [static, inherited]Prints the reference information to std::cout.
Definition at line 83 of file reference_counter.C.
Definition at line 123 of file reference_counter.h.
Threads::atomic< unsigned int > ReferenceCounter::_n_objects [static, protected, inherited]The number of objects. Print the reference count information when the number returns to 0.
Definition at line 118 of file reference_counter.h.
Referenced by ReferenceCounter::n_objects(), ReferenceCounter::ReferenceCounter(), and ReferenceCounter::~ReferenceCounter().
Author
Generated automatically by Doxygen for libMesh from the source code.