Public Member Functions | Protected Member Functions

mitk::BaseProcess Class Reference
[Process Classes]

Superclass of all classes generating some kind of mitk::BaseData. More...

#include <mitkBaseProcess.h>

Inheritance diagram for mitk::BaseProcess:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 mitkClassMacro (BaseProcess, itk::ProcessObject)
bool Updating () const
 Access itk::ProcessObject::m_Updating.
virtual void UnRegister () const
 Helps to deal with the weak-pointer-problem.
virtual int GetExternalReferenceCount () const
 Helps to deal with the weak-pointer-problem.

Protected Member Functions

 BaseProcess ()
virtual ~BaseProcess ()
virtual void SetNthOutput (unsigned int num, itk::DataObject *output)
 Protected methods for setting outputs.
virtual void AddOutput (itk::DataObject *output)
 Protected methods for setting outputs.

Detailed Description

Superclass of all classes generating some kind of mitk::BaseData.

Superclass of all classes generating some kind of mitk::BaseData. In itk and vtk the generated result of a ProcessObject is only guaranteed to be up-to-date, when Update() of the ProcessObject or the generated DataObject is called immediately before access of the data stored in the DataObject. This is also true for subclasses of mitk::BaseProcess. But many of the subclasses of mitk::BaseProcess define additional access functions to the generated output that guarantee an up-to-date result, see for example mitk::ImageSource.

Definition at line 45 of file mitkBaseProcess.h.


Constructor & Destructor Documentation

mitk::BaseProcess::BaseProcess (  ) [protected]

Definition at line 24 of file mitkBaseProcess.cpp.

                             : m_Unregistering(false), m_CalculatingExternalReferenceCount(false), m_ExternalReferenceCount(-1)
{

}
mitk::BaseProcess::~BaseProcess (  ) [protected, virtual]

Definition at line 29 of file mitkBaseProcess.cpp.

{

}

Member Function Documentation

void mitk::BaseProcess::AddOutput ( itk::DataObject *  output ) [protected, virtual]

Protected methods for setting outputs.

Subclasses make use of them for getting output. These are only overwritten because of itk::DataObject::ConnectSource being private and non-virtual: the important stuff is done in mitk::BaseData::ConnectSource.

Adds an output to the first null position in the output list. Expands the list memory if necessary

Definition at line 137 of file mitkBaseProcess.cpp.

{
#ifdef MITK_WEAKPOINTER_PROBLEM_WORKAROUND_ENABLED
  unsigned int idx=0;

  output = dynamic_cast<mitk::BaseData*>(output);

  if (output)
  {
    dynamic_cast<mitk::BaseData*>(output)->ConnectSource(this, idx);
  }
#endif
  Superclass::AddOutput(output);

}
int mitk::BaseProcess::GetExternalReferenceCount (  ) const [virtual]

Helps to deal with the weak-pointer-problem.

Definition at line 34 of file mitkBaseProcess.cpp.

{
  if(m_CalculatingExternalReferenceCount==false) //this is only needed because a smart-pointer to m_Outputs (private!!) must be created by calling GetOutputs.
  {
    m_CalculatingExternalReferenceCount = true;

    m_ExternalReferenceCount = -1;

    DataObjectPointerArray& outputs = const_cast<mitk::BaseProcess*>(this)->GetOutputs();

    int realReferenceCount = GetReferenceCount();

    unsigned int idx;
    for (idx = 0; idx < outputs.size(); ++idx)
    {
      //references of outputs that are not referenced from someone else (reference additional to the reference from this BaseProcess object) are interpreted as non-existent 
      if((outputs[idx]) && (outputs[idx]->GetReferenceCount()==1))
        --realReferenceCount;
    }
    m_ExternalReferenceCount = realReferenceCount;
    if(m_ExternalReferenceCount<0)
      m_ExternalReferenceCount=0;
  }
  else
    return -1;
  m_CalculatingExternalReferenceCount = false; //do not move in if-part!!!
  return m_ExternalReferenceCount;
}
mitk::BaseProcess::mitkClassMacro ( BaseProcess  ,
itk::ProcessObject   
)
void mitk::BaseProcess::SetNthOutput ( unsigned int  idx,
itk::DataObject *  output 
) [protected, virtual]

Protected methods for setting outputs.

Subclasses make use of them for getting output. These are only overwritten because of itk::DataObject::ConnectSource being private and non-virtual: the important stuff is done in mitk::BaseData::ConnectSource.

Set an output of this filter. This method specifically does not do a Register()/UnRegister() because of the desire to break the reference counting loop.

Reimplemented in mitk::ITKImageImport< TInputImage >.

Definition at line 112 of file mitkBaseProcess.cpp.

Referenced by mitk::ContourSetToPointSetFilter::ContourSetToPointSetFilter(), mitk::ExtractImageFilter::GenerateData(), mitk::GeometryDataSource::GeometryDataSource(), mitk::ImageSource::ImageSource(), mitk::PlanarFigureReader::PlanarFigureReader(), mitk::PointSetSource::PointSetSource(), mitk::PointSetToCurvedGeometryFilter::PointSetToCurvedGeometryFilter(), mitk::QBallImageSource::QBallImageSource(), mitk::UnstructuredGridSource::SetOutput(), mitk::SurfaceSource::SetOutput(), mitk::ImageSource::SetOutput(), mitk::GeometryDataSource::SetOutput(), mitk::SurfaceSource::SurfaceSource(), mitk::TensorImageSource::TensorImageSource(), TwoOutputsFilter::TwoOutputsFilter(), and mitk::UnstructuredGridSource::UnstructuredGridSource().

{
#ifdef MITK_WEAKPOINTER_PROBLEM_WORKAROUND_ENABLED
  output = dynamic_cast<mitk::BaseData*>(output);

  // does this change anything?
  if ( idx < GetOutputs().size() && output == GetOutputs()[idx])
  {
    return;
  }

  if (output)
  {
    dynamic_cast<mitk::BaseData*>(output)->ConnectSource(this, idx);
  }
#endif
  this->Register();
  Superclass::SetNthOutput(idx, output);
  this->UnRegister();
}
void mitk::BaseProcess::UnRegister (  ) const [virtual]

Helps to deal with the weak-pointer-problem.

Definition at line 63 of file mitkBaseProcess.cpp.

{
#ifdef MITK_WEAKPOINTER_PROBLEM_WORKAROUND_ENABLED
  if((m_Unregistering==false) && (m_CalculatingExternalReferenceCount==false))
  {
    m_Unregistering=true;

    int realReferenceCount = GetExternalReferenceCount()-1; //-1 because someone is trying to unregister us
    if(realReferenceCount<0)
      m_ExternalReferenceCount=realReferenceCount=0;

    if(realReferenceCount==0)
    {
      DataObjectPointerArray& outputs = const_cast<mitk::BaseProcess*>(this)->GetOutputs();
      //disconnect all outputs from us
      //size of outputs will not change until the very last output
      //is removed, because we remove from front to back
      unsigned int idx;
      for (idx = 0; idx < outputs.size(); ++idx)
      {
        const_cast<mitk::BaseProcess*>(this)->RemoveOutput(outputs[idx]);
      }
      //now the referenceCount should be one!
      int testReferenceCount=GetReferenceCount();
      if(testReferenceCount!=1)
      {
        itkWarningMacro(<<"Reference count of process object unexpectedly "
          << "not 1 before final unregister but " << testReferenceCount);
      }
    }
    m_Unregistering=false;
  }
  else
  {
    if(GetReferenceCount()==1)
    {
      //the calling UnRegister will do the last cleanup
      return;
    }
  }
#endif
  Superclass::UnRegister();
}
bool mitk::BaseProcess::Updating (  ) const [inline]

Access itk::ProcessObject::m_Updating.

m_Updating indicates when the pipeline is executing. It prevents infinite recursion when pipelines have loops.

See also:
itk::ProcessObject::m_Updating

Definition at line 56 of file mitkBaseProcess.h.

  {
    return m_Updating;
  }

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