Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | List of all members
Teuchos::RCPNodeTracer Class Reference

Debug-mode RCPNode tracing class. More...

#include <Teuchos_RCPNode.hpp>

Classes

struct  RCPNodeStatistics
 RCP statistics struct. More...
 

General user functions (can be called by any client)

static bool isTracingActiveRCPNodes ()
 Return if we are tracing active nodes or not. More...
 
static int numActiveRCPNodes ()
 Print the number of active RCPNode objects currently being tracked. More...
 
static RCPNodeStatistics getRCPNodeStatistics ()
 Return the statistics on RCPNode allocations. More...
 
static void printRCPNodeStatistics (const RCPNodeStatistics &rcpNodeStatistics, std::ostream &out)
 Print the RCPNode allocation statistics. More...
 
static void setPrintRCPNodeStatisticsOnExit (bool printRCPNodeStatisticsOnExit)
 Set if RCPNode usage statistics will be printed when the program ends or not. More...
 
static bool getPrintRCPNodeStatisticsOnExit ()
 Return if RCPNode usage statistics will be printed when the program ends or not. More...
 
static void setPrintActiveRcpNodesOnExit (bool printActiveRcpNodesOnExit)
 Set if printActiveRCPNodes() is called on exit from the program. More...
 
static bool getPrintActiveRcpNodesOnExit ()
 Return if printActiveRCPNodes() is called on exit from the program. More...
 
static void printActiveRCPNodes (std::ostream &out)
 Print the list of currently active RCP nodes. More...
 

Internal implementation functions (not to be called by general

clients).

static void addNewRCPNode (RCPNode *rcp_node, const std::string &info)
 Add new RCPNode to the global list. More...
 
static void removeRCPNode (RCPNode *rcp_node)
 Remove an RCPNode from global list. More...
 
template<class T >
static const void * getRCPNodeBaseObjMapKeyVoidPtr (T *p)
 Get a const void* address to be used as the lookup key for an RCPNode given its embedded object's typed pointer. More...
 
static RCPNodegetExistingRCPNodeGivenLookupKey (const void *lookupKey)
 Return a raw pointer to an existing owning RCPNode given its lookup key. More...
 
template<class T >
static RCPNodegetExistingRCPNode (T *p)
 Return a raw pointer to an existing owning RCPNode given the address to the underlying object if it exits. More...
 
static std::string getActiveRCPNodeHeaderString ()
 Header string used in printActiveRCPNodes(). More...
 
static std::string getCommonDebugNotesString ()
 Common error message string on how to debug RCPNode problems. More...
 

Detailed Description

Debug-mode RCPNode tracing class.

This is a static class that is used to trace all RCP nodes that are created and destroyed and to look-up RCPNodes given an an object's address. This database is used for several different types of debug-mode runtime checking including a) the detection of cicular references, b) detecting the creation of duplicate owning RCPNode objects for the same reference-counted object, and c) to create weak RCP objects for existing RCPNode objects.

This is primarily an internal implementation class but there are a few functions (maked as such below) that can be called by general users to turn on and off node tracing and to print the active RCPNode objects at any time.

Definition at line 368 of file Teuchos_RCPNode.hpp.

Member Function Documentation

bool Teuchos::RCPNodeTracer::isTracingActiveRCPNodes ( )
static

Return if we are tracing active nodes or not.

NOTE: This will always return false when TEUCHOS_DEBUG is not defined.

Definition at line 300 of file Teuchos_RCPNode.cpp.

int Teuchos::RCPNodeTracer::numActiveRCPNodes ( )
static

Print the number of active RCPNode objects currently being tracked.

Definition at line 314 of file Teuchos_RCPNode.cpp.

RCPNodeTracer::RCPNodeStatistics Teuchos::RCPNodeTracer::getRCPNodeStatistics ( )
static

Return the statistics on RCPNode allocations.

Definition at line 323 of file Teuchos_RCPNode.cpp.

void Teuchos::RCPNodeTracer::printRCPNodeStatistics ( const RCPNodeStatistics rcpNodeStatistics,
std::ostream &  out 
)
static

Print the RCPNode allocation statistics.

Definition at line 328 of file Teuchos_RCPNode.cpp.

void Teuchos::RCPNodeTracer::setPrintRCPNodeStatisticsOnExit ( bool  printRCPNodeStatisticsOnExit)
static

Set if RCPNode usage statistics will be printed when the program ends or not.

Definition at line 342 of file Teuchos_RCPNode.cpp.

bool Teuchos::RCPNodeTracer::getPrintRCPNodeStatisticsOnExit ( )
static

Return if RCPNode usage statistics will be printed when the program ends or not.

Definition at line 349 of file Teuchos_RCPNode.cpp.

void Teuchos::RCPNodeTracer::setPrintActiveRcpNodesOnExit ( bool  printActiveRcpNodesOnExit)
static

Set if printActiveRCPNodes() is called on exit from the program.

Definition at line 355 of file Teuchos_RCPNode.cpp.

bool Teuchos::RCPNodeTracer::getPrintActiveRcpNodesOnExit ( )
static

Return if printActiveRCPNodes() is called on exit from the program.

Definition at line 361 of file Teuchos_RCPNode.cpp.

void Teuchos::RCPNodeTracer::printActiveRCPNodes ( std::ostream &  out)
static

Print the list of currently active RCP nodes.

When the macro TEUCHOS_SHOW_ACTIVE_REFCOUNTPTR_NODE_TRACE is defined, this function will print out all of the RCP nodes that are currently active. This function can be called at any time during a program.

When the macro TEUCHOS_SHOW_ACTIVE_REFCOUNTPTR_NODE_TRACE is defined this function will get called automatically after the program ends by default and all of the local and global RCP objects have been destroyed. If any RCP nodes are printed at that time, then this is an indication that there may be some circular references that will caused memory leaks. You memory checking tool such as valgrind or purify should complain about this!

Definition at line 367 of file Teuchos_RCPNode.cpp.

void Teuchos::RCPNodeTracer::addNewRCPNode ( RCPNode rcp_node,
const std::string &  info 
)
static

Add new RCPNode to the global list.

Only gets called when RCPNode tracing has been activated.

Definition at line 422 of file Teuchos_RCPNode.cpp.

void Teuchos::RCPNodeTracer::removeRCPNode ( RCPNode rcp_node)
static

Remove an RCPNode from global list.

Always gets called in a debug build (TEUCHOS_DEBUG defined) when node tracing is enabled.

Definition at line 518 of file Teuchos_RCPNode.cpp.

template<class T >
static const void* Teuchos::RCPNodeTracer::getRCPNodeBaseObjMapKeyVoidPtr ( T *  p)
inlinestatic

Get a const void* address to be used as the lookup key for an RCPNode given its embedded object's typed pointer.

This only returns the base address reliabily for all types if HAS_TEUCHOS_GET_BASE_OBJ_VOID_PTR is defined.

Returns
0 if p == 0.

Definition at line 498 of file Teuchos_RCPNode.hpp.

RCPNode * Teuchos::RCPNodeTracer::getExistingRCPNodeGivenLookupKey ( const void *  lookupKey)
static

Return a raw pointer to an existing owning RCPNode given its lookup key.

Returns
returnVal != 0 if an owning RCPNode exists, 0 otherwsise.

Definition at line 579 of file Teuchos_RCPNode.cpp.

template<class T >
static RCPNode* Teuchos::RCPNodeTracer::getExistingRCPNode ( T *  p)
inlinestatic

Return a raw pointer to an existing owning RCPNode given the address to the underlying object if it exits.

Returns
returnVal != 0 if an owning RCPNode exists, 0 otherwsise.

Definition at line 528 of file Teuchos_RCPNode.hpp.

std::string Teuchos::RCPNodeTracer::getActiveRCPNodeHeaderString ( )
static

Header string used in printActiveRCPNodes().

Definition at line 604 of file Teuchos_RCPNode.cpp.

std::string Teuchos::RCPNodeTracer::getCommonDebugNotesString ( )
static

Common error message string on how to debug RCPNode problems.

Definition at line 631 of file Teuchos_RCPNode.cpp.


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