Medical Imaging Interaction Toolkit  2021.02.99-e55a5d2f
Medical Imaging Interaction Toolkit
berry::HandleObject Class Referenceabstract

#include <berryHandleObject.h>

Inheritance diagram for berry::HandleObject:
Collaboration diagram for berry::HandleObject:

Public Member Functions

 berryObjectMacro (HandleObject)
bool operator== (const Object *object) const override
QString GetId () const
uint HashCode () const override
bool IsDefined () const
virtual void Undefine ()=0
- Public Member Functions inherited from berry::Object
virtual QString GetClassName () const
virtual Reflection::TypeInfo GetTypeInfo () const
virtual QList< Reflection::TypeInfoGetSuperclasses () const
virtual void Delete ()
QDebug Print (QDebug os, Indent Indent=0) const
virtual QString ToString () const
virtual bool operator< (const Object *) const
void Register () const
void UnRegister (bool del=true) const
int GetReferenceCount () const
void SetReferenceCount (int)
void AddDestroyListener (const MessageAbstractDelegate<> &delegate) const
void RemoveDestroyListener (const MessageAbstractDelegate<> &delegate) const

Protected Member Functions

 HandleObject (const QString &id)
- Protected Member Functions inherited from berry::Object
 Object ()
virtual ~Object ()
virtual QDebug PrintSelf (QDebug os, Indent indent) const
virtual QDebug PrintHeader (QDebug os, Indent indent) const
virtual QDebug PrintTrailer (QDebug os, Indent indent) const

Protected Attributes

bool defined
const QString id
QString str
- Protected Attributes inherited from berry::Object
QAtomicInt m_ReferenceCount
QMutex m_ReferenceCountLock

Additional Inherited Members

- Public Types inherited from berry::Object
typedef Object Self
typedef berry::SmartPointer< SelfPointer
typedef berry::SmartPointer< const SelfConstPointer
typedef berry::WeakPointer< SelfWeakPtr
typedef berry::WeakPointer< const SelfConstWeakPtr
- Static Public Member Functions inherited from berry::Object
static const char * GetStaticClassName ()
static Reflection::TypeInfo GetStaticTypeInfo ()
static QList< Reflection::TypeInfoGetStaticSuperclasses ()

Detailed Description

An object that can exist in one of two states: defined and undefined. This is used by APIs that want to give a handle to an object, even though the object does not fully exist yet. This way, users can attach listeners to objects before they come into existence. It also protects the API from users that do not release references when they should.

To enforce good coding practice, all handle objects must implement equals and toString. Please use string to cache the result for toString once calculated.

All handle objects are referred to using a single identifier. This identifier is a instance of String. It is important that this identifier remain unique within whatever context that handle object is being used. For example, there should only ever be one instance of Command with a given identifier.


Definition at line 48 of file berryHandleObject.h.

Constructor & Destructor Documentation

◆ HandleObject()

berry::HandleObject::HandleObject ( const QString &  id)

Constructs a new instance of HandleObject.

idThe id of this handle; must not be null.

Member Function Documentation

◆ berryObjectMacro()

berry::HandleObject::berryObjectMacro ( HandleObject  )

◆ GetId()

QString berry::HandleObject::GetId ( ) const

◆ HashCode()

uint berry::HandleObject::HashCode ( ) const

Computes the hash code for this object based on the id.

The hash code for this object.

Reimplemented from berry::Object.

Definition at line 131 of file berryHandleObject.h.

References qHash().

◆ IsDefined()

bool berry::HandleObject::IsDefined ( ) const

Whether this instance is defined. A defined instance is one that has been fully initialized. This allows objects to effectively disappear even though other objects may still have references to them.

true if this object is defined; false otherwise.

◆ operator==()

bool berry::HandleObject::operator== ( const Object object) const

Tests whether this object is equal to another object. A handle object is only equal to another handle object with the same id and the same class.

objectThe object with which to compare; may be null.
true if the objects are equal; false otherwise.

Reimplemented from berry::Object.

◆ Undefine()

virtual void berry::HandleObject::Undefine ( )
pure virtual

Makes this object becomes undefined. This method should make any defined properties null. It should also send notification to any listeners that these properties have changed.

Implemented in berry::Command, berry::ParameterType, and berry::CommandCategory.

Member Data Documentation

◆ defined

bool berry::HandleObject::defined

Whether this object is defined. A defined object is one that has been fully initialized. By default, all objects start as undefined.

Definition at line 85 of file berryHandleObject.h.

◆ id

const QString berry::HandleObject::id

The identifier for this object. This identifier should be unique across all objects of the same type and should never change. This value will never be null.

Definition at line 92 of file berryHandleObject.h.

◆ str

QString berry::HandleObject::str

The string representation of this object. This string is for debugging purposes only, and is not meant to be displayed to the user. This value is computed lazily, and is cleared if one of its dependent values changes.

Definition at line 100 of file berryHandleObject.h.

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