13 #ifndef mitkReferenceCountWatcher_h
14 #define mitkReferenceCountWatcher_h
16 #include <itkCommand.h>
32 typedef itk::SimpleMemberCommand<ReferenceCountWatcher>
CommandType;
85 return m_Object->GetReferenceCount();
89 itkGetStringMacro(Comment);
Keeps track of the reference count of an object even if it is destroyed.
~ReferenceCountWatcher() override
Destructor. Removes the observer from the watched object if it still exists.
bool m_Deleted
If true, m_Object is no longer valid and the returned reference count will be 0.
void DeleteObserver()
Callback invoked on itk::DeleteEvent() of the watched object.
ReferenceCountWatcher(itk::Object *o, const char *comment="")
Constructor requiring the object to be watched and allowing an optional comment.
itk::Object * m_Object
The object to be watched.
mitkClassMacroItkParent(ReferenceCountWatcher, itk::Object)
itk::SimpleMemberCommand< ReferenceCountWatcher > CommandType
int GetReferenceCount() const override
Returns the reference count of the watched object.
std::string m_Comment
Optional comment, e.g. for debugging output.
unsigned long m_ObserverTag
ITK observer tag for the delete event.
CommandType::Pointer m_DeleteCommand
itk::Command to get a notification when the object is deleted.
Find image slices visible on a given plane.