Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

mitk::SmartPointerProperty Class Reference
[Data Management Classes]

Property containing a smart-pointer. More...

#include <mitkSmartPointerProperty.h>

Inheritance diagram for mitk::SmartPointerProperty:
Inheritance graph
[legend]
Collaboration diagram for mitk::SmartPointerProperty:
Collaboration graph
[legend]

List of all members.

Public Types

typedef SmartPointerProperty Self
typedef BaseProperty Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer

Public Member Functions

virtual const char * GetClassName () const
virtual bool operator== (const BaseProperty &) const
 Subclasses must implement this operator==. Operator== which is used by PropertyList to check whether a property has been changed.
virtual ~SmartPointerProperty ()
itk::Object::Pointer GetSmartPointer () const
void SetSmartPointer (itk::Object *)
virtual std::string GetValueAsString () const
 mainly for XML output
virtual bool Assignable (const BaseProperty &) const
virtual BasePropertyoperator= (const BaseProperty &property)

Static Public Member Functions

static Pointer New ()
static Pointer New (itk::Object *_arg)
static void PostProcessXMLReading ()
static unsigned int GetReferenceCountFor (itk::Object *)
 Return the number of SmartPointerProperties that reference the object given as parameter.
static std::string GetReferenceUIDFor (itk::Object *)
static void RegisterPointerTarget (itk::Object *, const std::string uid)

Protected Member Functions

 SmartPointerProperty (itk::Object *=NULL)

Protected Attributes

itk::Object::Pointer m_SmartPointer

Detailed Description

Property containing a smart-pointer.

Definition at line 35 of file mitkSmartPointerProperty.h.


Member Typedef Documentation

typedef itk::SmartPointer<const Self> mitk::SmartPointerProperty::ConstPointer

Reimplemented from mitk::BaseProperty.

Definition at line 38 of file mitkSmartPointerProperty.h.

typedef itk::SmartPointer<Self> mitk::SmartPointerProperty::Pointer

Reimplemented from mitk::BaseProperty.

Definition at line 38 of file mitkSmartPointerProperty.h.

Reimplemented from mitk::BaseProperty.

Definition at line 38 of file mitkSmartPointerProperty.h.

Reimplemented from mitk::BaseProperty.

Definition at line 38 of file mitkSmartPointerProperty.h.


Constructor & Destructor Documentation

mitk::SmartPointerProperty::~SmartPointerProperty (  ) [virtual]

Definition at line 86 of file mitkSmartPointerProperty.cpp.

{
}
mitk::SmartPointerProperty::SmartPointerProperty ( itk::Object *  pointer = NULL ) [protected]

Definition at line 81 of file mitkSmartPointerProperty.cpp.

{
  SetSmartPointer( pointer );
}

Member Function Documentation

bool mitk::SmartPointerProperty::Assignable ( const BaseProperty  ) const [virtual]

Should be implemented by subclasses to indicate whether they can accept the parameter as the right-hand-side argument of an assignment. This test will most probably include some dynamic_cast.

Reimplemented from mitk::BaseProperty.

Definition at line 125 of file mitkSmartPointerProperty.cpp.

{
  try
  {
    dynamic_cast<const Self&>(other); // dear compiler, please don't optimize this away!
    return true;
  }
  catch (std::bad_cast)
  {
  }
  return false;
}
virtual const char* mitk::SmartPointerProperty::GetClassName (  ) const [virtual]

Reimplemented from mitk::BaseProperty.

unsigned int mitk::SmartPointerProperty::GetReferenceCountFor ( itk::Object *  object ) [static]

Return the number of SmartPointerProperties that reference the object given as parameter.

Returns:
The number of SmartPointerProperties that point to
Parameters:
object

Definition at line 43 of file mitkSmartPointerProperty.cpp.

{
  if ( m_ReferenceCount.find(object) != m_ReferenceCount.end() )
  {
    return m_ReferenceCount[object];
  }
  else
  {
    return 0;
  }
}
std::string mitk::SmartPointerProperty::GetReferenceUIDFor ( itk::Object *  object ) [static]

Definition at line 60 of file mitkSmartPointerProperty.cpp.

{
  if ( m_ReferencesUID.find(object) != m_ReferencesUID.end() )
  {
    return m_ReferencesUID[object];
  }
  else
  {
    return std::string("invalid");
  }
}
itk::Object::Pointer mitk::SmartPointerProperty::GetSmartPointer (  ) const
std::string mitk::SmartPointerProperty::GetValueAsString (  ) const [virtual]

mainly for XML output

Reimplemented from mitk::BaseProperty.

Definition at line 117 of file mitkSmartPointerProperty.cpp.

{
  if ( m_SmartPointer.IsNotNull() )
    return m_ReferencesUID[ m_SmartPointer.GetPointer() ];
  else
    return std::string("NULL");
}
static Pointer mitk::SmartPointerProperty::New (  ) [static]
static Pointer mitk::SmartPointerProperty::New ( itk::Object *  _arg ) [inline, static]

Definition at line 41 of file mitkSmartPointerProperty.h.

mitk::BaseProperty & mitk::SmartPointerProperty::operator= ( const BaseProperty rhs ) [virtual]

To be implemented more meaningful by subclasses. This version just accepts the assignment of BaseProperty objects to others, but the assignment has NO MEANING, values are not changed at all!

Reimplemented from mitk::BaseProperty.

Definition at line 138 of file mitkSmartPointerProperty.cpp.

{
  try
  {
    const Self& otherProp( dynamic_cast<const Self&>(other) );

    if (this->m_SmartPointer != otherProp.m_SmartPointer)
    {
      this->m_SmartPointer = otherProp.m_SmartPointer;
      this->Modified();
    }
  }
  catch (std::bad_cast)
  {
    // nothing to do then
  }

  return *this;
}
bool mitk::SmartPointerProperty::operator== ( const BaseProperty property ) const [virtual]

Subclasses must implement this operator==. Operator== which is used by PropertyList to check whether a property has been changed.

Implements mitk::BaseProperty.

Definition at line 72 of file mitkSmartPointerProperty.cpp.

{
    const Self *other = dynamic_cast<const Self*>(&property);

    if(other==NULL) return false;

    return other->m_SmartPointer==m_SmartPointer;
}
void mitk::SmartPointerProperty::PostProcessXMLReading (  ) [static]

Definition at line 27 of file mitkSmartPointerProperty.cpp.

{
  for (ReadInSmartPointersMapType::iterator iter = m_ReadInInstances.begin();
       iter != m_ReadInInstances.end();
       ++iter)
  {
    if ( m_ReadInTargets.find(iter->second) != m_ReadInTargets.end() )
    {
      iter->first->SetSmartPointer(  m_ReadInTargets[ iter->second ] );
    }
  }

  m_ReadInInstances.clear();
}
void mitk::SmartPointerProperty::RegisterPointerTarget ( itk::Object *  object,
const std::string  uid 
) [static]

Definition at line 55 of file mitkSmartPointerProperty.cpp.

{
  m_ReadInTargets[uid] = object;
}
void mitk::SmartPointerProperty::SetSmartPointer ( itk::Object *  pointer )

Definition at line 95 of file mitkSmartPointerProperty.cpp.

{
  if(m_SmartPointer.GetPointer() != pointer)
  {
    // keep track of referenced objects
    if ( m_SmartPointer.GetPointer() && --m_ReferenceCount[m_SmartPointer.GetPointer()] == 0 ) // if there is no reference left, delete entry
    {
      m_ReferenceCount.erase( m_SmartPointer.GetPointer() );
      m_ReferencesUID.erase( m_SmartPointer.GetPointer() );
    }

    if ( pointer && ++m_ReferenceCount[pointer] == 1 ) // first reference --> generate UID
    {
      m_ReferencesUID[pointer] = m_UIDGenerator.GetUID();
    }
    
    // change pointer
    m_SmartPointer = pointer;
    Modified();
  }
}

Member Data Documentation

itk::Object::Pointer mitk::SmartPointerProperty::m_SmartPointer [protected]

Definition at line 70 of file mitkSmartPointerProperty.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines