SimpleITK  
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
itk::simple::ObjectOwnedBase Class Referenceabstract

An abstract base class to connect this object with the lifetime of another. More...

#include <sitkObjectOwnedBase.h>

+ Inheritance diagram for itk::simple::ObjectOwnedBase:
+ Collaboration diagram for itk::simple::ObjectOwnedBase:

Public Member Functions

virtual std::string GetName () const
 
 ObjectOwnedBase ()=default
 
virtual void SetName (const std::string &name)
 
virtual ~ObjectOwnedBase ()=0
 
- Public Member Functions inherited from itk::simple::NonCopyable
 NonCopyable (const NonCopyable &)=delete
 
NonCopyableoperator= (const NonCopyable &)=delete
 

Protected Member Functions

virtual size_t AddObjectCallback (itk::Object *o, std::function< void()> onDelete)
 Register an Object and a method to call on this object's destructor. More...
 
 ObjectOwnedBase (const ObjectOwnedBase &o)
 Copy Constructor. More...
 
virtual size_t RemoveObject (const itk::Object *)
 
virtual void SetOwnedByObjects (bool o)
 
virtual bool GetOwnedByObjects () const
 
virtual void OwnedByObjectsOn ()
 
virtual void OwnedByObjectsOff ()
 
- Protected Member Functions inherited from itk::simple::NonCopyable
 NonCopyable ()=default
 

Private Member Functions

void ExecuteCallbacks (void)
 

Private Attributes

std::string m_Name
 
bool m_OwnedByObjects { false }
 
std::multimap< itk::Object *, std::function< void()> > m_ReferencedObjectsCallbacks
 

Detailed Description

An abstract base class to connect this object with the lifetime of another.

This class maintains a list of Objects and callbacks to call when this object is deleted.

Optionally, "OwnedByObjects" property can be enabled so that when the last referenced object is removed this object will be deleted.

Definition at line 47 of file sitkObjectOwnedBase.h.

Constructor & Destructor Documentation

◆ ~ObjectOwnedBase()

virtual itk::simple::ObjectOwnedBase::~ObjectOwnedBase ( )
pure virtual

◆ ObjectOwnedBase() [1/2]

itk::simple::ObjectOwnedBase::ObjectOwnedBase ( )
default

◆ ObjectOwnedBase() [2/2]

itk::simple::ObjectOwnedBase::ObjectOwnedBase ( const ObjectOwnedBase o)
protected

Copy Constructor.

Only copiable if o does not have OwnedByObjects enabled. If OwnedByObjects is enabled in o, than an exception will be thrown.

The object callbacks are copied to the new object.

Member Function Documentation

◆ AddObjectCallback()

virtual size_t itk::simple::ObjectOwnedBase::AddObjectCallback ( itk::Object o,
std::function< void()>  onDelete 
)
protectedvirtual

Register an Object and a method to call on this object's destructor.

Parameters
o
onDeleteA function object to be called
Returns
The number of currently registered objects or functions.

◆ ExecuteCallbacks()

void itk::simple::ObjectOwnedBase::ExecuteCallbacks ( void  )
private

◆ GetName()

virtual std::string itk::simple::ObjectOwnedBase::GetName ( ) const
virtual

Set object name.

Reimplemented in itk::simple::LoggerBase, and itk::simple::Command.

◆ GetOwnedByObjects()

virtual bool itk::simple::ObjectOwnedBase::GetOwnedByObjects ( ) const
protectedvirtual

Set/Get the OwnedByObject attribute.

Indicates that ownership of this object is by object's in the ObjectCallbacks and that this object was dynamically allocated on the heap.

If true, when all objects have been removed by "RemovedObject", then this will be deleted.

◆ OwnedByObjectsOff()

virtual void itk::simple::ObjectOwnedBase::OwnedByObjectsOff ( )
protectedvirtual

Set/Get the OwnedByObject attribute.

Indicates that ownership of this object is by object's in the ObjectCallbacks and that this object was dynamically allocated on the heap.

If true, when all objects have been removed by "RemovedObject", then this will be deleted.

◆ OwnedByObjectsOn()

virtual void itk::simple::ObjectOwnedBase::OwnedByObjectsOn ( )
protectedvirtual

Set/Get the OwnedByObject attribute.

Indicates that ownership of this object is by object's in the ObjectCallbacks and that this object was dynamically allocated on the heap.

If true, when all objects have been removed by "RemovedObject", then this will be deleted.

◆ RemoveObject()

virtual size_t itk::simple::ObjectOwnedBase::RemoveObject ( const itk::Object )
protectedvirtual

◆ SetName()

virtual void itk::simple::ObjectOwnedBase::SetName ( const std::string &  name)
virtual

Get object name.

Reimplemented in itk::simple::LoggerBase, and itk::simple::Command.

◆ SetOwnedByObjects()

virtual void itk::simple::ObjectOwnedBase::SetOwnedByObjects ( bool  o)
protectedvirtual

Set/Get the OwnedByObject attribute.

Indicates that ownership of this object is by object's in the ObjectCallbacks and that this object was dynamically allocated on the heap.

If true, when all objects have been removed by "RemovedObject", then this will be deleted.

Member Data Documentation

◆ m_Name

std::string itk::simple::ObjectOwnedBase::m_Name
private

Definition at line 119 of file sitkObjectOwnedBase.h.

◆ m_OwnedByObjects

bool itk::simple::ObjectOwnedBase::m_OwnedByObjects { false }
private

Definition at line 117 of file sitkObjectOwnedBase.h.

◆ m_ReferencedObjectsCallbacks

std::multimap<itk::Object *, std::function<void()> > itk::simple::ObjectOwnedBase::m_ReferencedObjectsCallbacks
private

Definition at line 118 of file sitkObjectOwnedBase.h.


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