17 #include "itkCommand.h"
38 typedef itk::SimpleMemberCommand<ReferenceCountWatcher>
CommandType;
66 : m_Object(o), m_Comment(comment), m_Deleted(false),
m_ObserverTag(0)
71 m_ObserverTag = m_Object->AddObserver(itk::DeleteEvent(), m_DeleteCommand);
78 if ((m_Deleted ==
false) && (m_Object != NULL))
92 return m_Object->GetReferenceCount();
97 itkGetStringMacro(Comment);
itk::Object * m_Object
Object to be watched.
itk::SmartPointer< Self > Pointer
DataCollection - Class to facilitate loading/accessing structured data.
unsigned long m_ObserverTag
bool m_Deleted
If true, m_Object is no longer valid and the returned reference count will be 0.
std::string m_Comment
Optional comment, e.g. for debugging output.
itk::SimpleMemberCommand< ReferenceCountWatcher > CommandType
~ReferenceCountWatcher()
Destructor: remove observer.
ReferenceCountWatcher(itk::Object *o, const char *comment="")
Constructor requiring object to be watched and allowing an optional comment.
Keeps track of the reference count of an object even if it is destroyed.
#define mitkClassMacroItkParent(className, SuperClassName)
int GetReferenceCount() const override
Return the reference count of the watched object or 0 if it has been destroyed.
void DeleteObserver()
Callback called on itk::DeleteEvent() of wathched object.
CommandType::Pointer m_DeleteCommand
itk::Command to get a notification when the object is deleted.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.