Medical Imaging Interaction Toolkit  2023.12.00
Medical Imaging Interaction Toolkit
mitk::ReferenceCountWatcher Class Reference

Keeps track of the reference count of an object even if it is destroyed. More...

#include <mitkReferenceCountWatcher.h>

Inheritance diagram for mitk::ReferenceCountWatcher:
Collaboration diagram for mitk::ReferenceCountWatcher:

Public Types

typedef itk::SimpleMemberCommand< ReferenceCountWatcherCommandType
 
typedef ReferenceCountWatcher Self
 
typedef itk::Object Superclass
 
typedef itk::SmartPointer< SelfPointer
 
typedef itk::SmartPointer< const SelfConstPointer
 

Public Member Functions

virtual std::vector< std::string > GetClassHierarchy () const
 
virtual const char * GetClassName () const
 
 ReferenceCountWatcher (itk::Object *o, const char *comment="")
 Constructor requiring object to be watched and allowing an optional comment. More...
 
 ~ReferenceCountWatcher () override
 Destructor: remove observer. More...
 
int GetReferenceCount () const override
 Return the reference count of the watched object or 0 if it has been destroyed. More...
 
virtual const char * GetComment () const
 Return the optional string comment. More...
 

Static Public Member Functions

static const char * GetStaticNameOfClass ()
 

Protected Member Functions

void DeleteObserver ()
 Callback called on itk::DeleteEvent() of wathched object. More...
 

Protected Attributes

itk::Object * m_Object
 Object to be watched. More...
 
std::string m_Comment
 Optional comment, e.g. for debugging output. More...
 
bool m_Deleted
 If true, m_Object is no longer valid and the returned reference count will be 0. More...
 
CommandType::Pointer m_DeleteCommand
 itk::Command to get a notification when the object is deleted. More...
 
unsigned long m_ObserverTag
 

Detailed Description

Keeps track of the reference count of an object even if it is destroyed.

Definition at line 26 of file mitkReferenceCountWatcher.h.

Member Typedef Documentation

◆ CommandType

Definition at line 29 of file mitkReferenceCountWatcher.h.

◆ ConstPointer

◆ Pointer

◆ Self

◆ Superclass

Definition at line 31 of file mitkReferenceCountWatcher.h.

Constructor & Destructor Documentation

◆ ReferenceCountWatcher()

mitk::ReferenceCountWatcher::ReferenceCountWatcher ( itk::Object *  o,
const char *  comment = "" 
)
inline

Constructor requiring object to be watched and allowing an optional comment.

Definition at line 56 of file mitkReferenceCountWatcher.h.

References DeleteObserver(), m_DeleteCommand, m_Object, and m_ObserverTag.

◆ ~ReferenceCountWatcher()

mitk::ReferenceCountWatcher::~ReferenceCountWatcher ( )
inlineoverride

Destructor: remove observer.

Definition at line 67 of file mitkReferenceCountWatcher.h.

References m_Deleted, m_Object, and m_ObserverTag.

Member Function Documentation

◆ DeleteObserver()

void mitk::ReferenceCountWatcher::DeleteObserver ( )
inlineprotected

Callback called on itk::DeleteEvent() of wathched object.

Definition at line 93 of file mitkReferenceCountWatcher.h.

References m_Deleted.

Referenced by ReferenceCountWatcher().

◆ GetClassHierarchy()

virtual std::vector<std::string> mitk::ReferenceCountWatcher::GetClassHierarchy ( ) const
inlinevirtual

Definition at line 31 of file mitkReferenceCountWatcher.h.

◆ GetClassName()

virtual const char* mitk::ReferenceCountWatcher::GetClassName ( ) const
virtual

◆ GetComment()

virtual const char* mitk::ReferenceCountWatcher::GetComment ( ) const
virtual

Return the optional string comment.

◆ GetReferenceCount()

int mitk::ReferenceCountWatcher::GetReferenceCount ( ) const
inlineoverride

Return the reference count of the watched object or 0 if it has been destroyed.

Definition at line 77 of file mitkReferenceCountWatcher.h.

References m_Deleted, and m_Object.

◆ GetStaticNameOfClass()

static const char* mitk::ReferenceCountWatcher::GetStaticNameOfClass ( )
inlinestatic

Definition at line 31 of file mitkReferenceCountWatcher.h.

Member Data Documentation

◆ m_Comment

std::string mitk::ReferenceCountWatcher::m_Comment
protected

Optional comment, e.g. for debugging output.

Definition at line 40 of file mitkReferenceCountWatcher.h.

◆ m_DeleteCommand

CommandType::Pointer mitk::ReferenceCountWatcher::m_DeleteCommand
protected

itk::Command to get a notification when the object is deleted.

Definition at line 50 of file mitkReferenceCountWatcher.h.

Referenced by ReferenceCountWatcher().

◆ m_Deleted

bool mitk::ReferenceCountWatcher::m_Deleted
protected

If true, m_Object is no longer valid and the returned reference count will be 0.

Definition at line 45 of file mitkReferenceCountWatcher.h.

Referenced by DeleteObserver(), GetReferenceCount(), and ~ReferenceCountWatcher().

◆ m_Object

itk::Object* mitk::ReferenceCountWatcher::m_Object
protected

Object to be watched.

Definition at line 31 of file mitkReferenceCountWatcher.h.

Referenced by GetReferenceCount(), ReferenceCountWatcher(), and ~ReferenceCountWatcher().

◆ m_ObserverTag

unsigned long mitk::ReferenceCountWatcher::m_ObserverTag
protected

Definition at line 94 of file mitkReferenceCountWatcher.h.

Referenced by ReferenceCountWatcher(), and ~ReferenceCountWatcher().


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