Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkMacro.h File Reference

Go to the source code of this file.

Namespaces

namespace  itk

Defines

#define itkNotUsed(x)
#define itkStaticConstMacro(name, type, value)   static const type name = value
#define itkGetStaticConstMacro(name)   (Self::name)
#define itkGetStringMacro(name)
#define itkGetVectorMacro(name, type, count)
#define itkTypeMacro(thisClass, superclass)
#define itkGenericExceptionMacro(x)
#define itkGenericOutputMacro(x)
#define itkLogMacro(x, y)
#define itkLogMacroStatic(obj, x, y)
#define itkLegacy(method)   method
#define itkLegacyBody(method, version)   itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
#define itkLegacyReplaceBody(method, version, replace)   itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version. Use " #replace " instead.")


Define Documentation

#define itkBooleanMacro name   ) 
 

Value:

virtual void name##On () { this->Set##name(true);} \
  virtual void name##Off () { this->Set##name(false);}
Create members "name"On() and "name"Off() (e.g., DebugOn() DebugOff()). Set method must be defined to use this macro.

Definition at line 293 of file itkMacro.h.

#define itkDebugMacro  ) 
 

Value:

{ if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay())   \
    { ::itk::OStringStream itkmsg; \
      itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \
             << this->GetNameOfClass() << " (" << this << "): " x  \
             << "\n\n"; \
      ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str());} \
}
This macro is used to print debug (or other information). They are also used to catch errors, etc. Example usage looks like: itkDebugMacro(<< "this is debug info" << this->SomeVariable);

Definition at line 422 of file itkMacro.h.

#define itkExceptionMacro  ) 
 

Value:

{ \
  ::itk::OStringStream message; \
  message << "itk::ERROR: " << this->GetNameOfClass() \
          << "(" << this << "): " x; \
  ::itk::ExceptionObject e_(__FILE__, __LINE__, message.str().c_str()); \
  throw e_;   \
  }
The exception macro is used to print error information (i.e., usually a condition that results in program failure). Example usage looks like: itkExceptionMacro(<< "this is error info" << this->SomeVariable);

Definition at line 509 of file itkMacro.h.

Referenced by itk::DiffusionTensor3DReconstructionImageFilter< TReferenceImagePixelType, TGradientImagePixelType, TTensorPixelType >::GetGradientDirection(), itk::BSplineDeformableTransform< TScalarType, NDimensions, VSplineOrder >::GetNumberOfWeights(), itk::Transform< TScalarType, 3, 2 >::GetParameters(), itk::STAPLEImageFilter< TInputImage, TOutputImage >::GetSensitivity(), itk::STAPLEImageFilter< TInputImage, TOutputImage >::GetSpecificity(), itk::Statistics::NeighborhoodSampler< TSample >::SetCenter(), itk::Transform< TScalarType, 3, 2 >::SetFixedParameters(), itk::Statistics::ListSampleToHistogramGenerator< TListSample, THistogramMeasurement, TFrequencyContainer, TMeasurementVectorLength >::SetHistogramMax(), itk::Statistics::ListSampleToHistogramGenerator< TListSample, THistogramMeasurement, TFrequencyContainer, TMeasurementVectorLength >::SetHistogramMin(), itk::MultiResolutionPDEDeformableRegistration< TFixedImage, TMovingImage, TDeformationField >::SetInitialDeformationField(), itk::WatershedImageFilter< TInputImage >::SetInput(), itk::GDCMSeriesFileNames::SetInputDirectory(), itk::Statistics::ListSampleToHistogramGenerator< TListSample, THistogramMeasurement, TFrequencyContainer, TMeasurementVectorLength >::SetListSample(), itk::Statistics::ScalarImageToListAdaptor< TImage >::SetMeasurementVectorSize(), itk::Statistics::PointSetToListAdaptor< TPointSet >::SetMeasurementVectorSize(), itk::Statistics::JointDomainImageToListAdaptor< TImage >::SetMeasurementVectorSize(), itk::Statistics::ImageToListAdaptor< TImage, FixedArray< TImage::PixelType, 1 > >::SetMeasurementVectorSize(), itk::Statistics::Histogram< THistogramMeasurement, 1 >::SetMeasurementVectorSize(), and itk::Transform< TScalarType, 3, 2 >::SetParameters().

#define itkFactorylessNewMacro  ) 
 

Value:

static Pointer New(void) \
{ \
  Pointer smartPtr; \
  x *rawPtr = new x; \
  smartPtr = rawPtr; \
  rawPtr->UnRegister(); \
  return smartPtr; \
} \
virtual LightObject::Pointer CreateAnother(void) const \
{ \
  LightObject::Pointer smartPtr; \
  smartPtr = x::New().GetPointer(); \
  return smartPtr; \
}
Define two object creation methods. The first method, New(), creates an object from a class but does not defer to a factory. The second method, CreateAnother(), creates an object from an instance, again without deferring to a factory. This second method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.

These creation methods first try asking the object factory to create an instance, and then default to the standard "new" operator if the factory fails.

These routines assigns the raw pointer to a smart pointer and then call UnRegister() on the rawPtr to compensate for LightObject's constructor initializing an object's reference count to 1 (needed for proper initialization of process objects and data objects cycles).

Definition at line 376 of file itkMacro.h.

#define itkGenericExceptionMacro  ) 
 

Value:

{ \
  ::itk::OStringStream message; \
  message << "itk::ERROR: " x; \
  ::itk::ExceptionObject e_(__FILE__, __LINE__, message.str().c_str()); \
  throw e_;   \
  }

Definition at line 519 of file itkMacro.h.

Referenced by itk::MeasurementVectorTraits::Assert(), itk::Statistics::ListSampleBase< ImageJointDomainTraits< TImage >::MeasurementVectorType >::Search(), and itk::MeasurementVectorTraits::SetLength().

#define itkGenericOutputMacro  ) 
 

Value:

{ if (::itk::Object::GetGlobalWarningDisplay()) \
    { ::itk::OStringStream itkmsg; \
      itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \
             x << "\n\n"; \
      itk::OutputWindowDisplayGenericOutputText(itkmsg.str().c_str());} \
}

Definition at line 530 of file itkMacro.h.

#define itkGetConstMacro name,
type   ) 
 

Value:

virtual type Get##name () const \
  { \
    itkDebugMacro("returning " << #name " of " << this->m_##name ); \
    return this->m_##name; \
  }
Get built-in type. Creates member Get"name"() (e.g., GetVisibility()); This is the "const" form of the itkGetMacro. It should be used unless the member can be changed through the "Get" access routine.

Definition at line 164 of file itkMacro.h.

#define itkGetConstObjectMacro name,
type   ) 
 

Value:

virtual const type * Get##name () const \
  { \
    itkDebugMacro("returning " #name " address " << this->m_##name ); \
    return this->m_##name.GetPointer(); \
  }
Get a smart const pointer to an object. Creates the member Get"name"() (e.g., GetPoints()).

Definition at line 273 of file itkMacro.h.

#define itkGetConstReferenceMacro name,
type   ) 
 

Value:

virtual const type & Get##name () const \
  { \
    itkDebugMacro("returning " << #name " of " << this->m_##name ); \
    return this->m_##name; \
  }
Get built-in type. Creates member Get"name"() (e.g., GetVisibility()); This is the "const" form of the itkGetMacro. It should be used unless the member can be changed through the "Get" access routine. This versions returns a const reference to the variable.

Definition at line 176 of file itkMacro.h.

#define itkGetConstReferenceObjectMacro name,
type   ) 
 

Value:

virtual const typename type::Pointer & Get##name () const \
  { \
    itkDebugMacro("returning " #name " address " << this->m_##name ); \
    return this->m_##name; \
  }
Get a const reference to a smart pointer to an object. Creates the member Get"name"() (e.g., GetPoints()).

Definition at line 283 of file itkMacro.h.

#define itkGetInputMacro name,
type,
number   ) 
 

Value:

virtual const type * Get##name##Input() const \
  { \
    itkDebugMacro("returning input " << #name " of " << static_cast<const type *>(this->ProcessObject::GetInput( number )) ); \
    return static_cast<const type *>(this->ProcessObject::GetInput( number )); \
  } \
  virtual const type * GetInput##number() const \
  { \
    itkDebugMacro("returning input " << #number " of " << static_cast<const type *>(this->ProcessObject::GetInput( number )) ); \
    return static_cast<const type *>(this->ProcessObject::GetInput( number )); \
  }
Get an input. This defines the Get"name"Input() method

Definition at line 125 of file itkMacro.h.

#define itkGetMacro name,
type   ) 
 

Value:

virtual type Get##name () \
  { \
    itkDebugMacro("returning " << #name " of " << this->m_##name ); \
    return this->m_##name; \
  }
Get built-in type. Creates member Get"name"() (e.g., GetVisibility());

Definition at line 153 of file itkMacro.h.

#define itkGetObjectMacro name,
type   ) 
 

Value:

virtual type * Get##name () \
  { \
    itkDebugMacro("returning " #name " address " << this->m_##name ); \
    return this->m_##name.GetPointer(); \
  }
Get a smart pointer to an object. Creates the member Get"name"() (e.g., GetPoints()).

Definition at line 246 of file itkMacro.h.

#define itkGetStaticConstMacro name   )     (Self::name)
 

Definition at line 98 of file itkMacro.h.

Referenced by itk::LabelStatisticsImageFilter< TInputImage, TLabelImage >::LabelStatistics::LabelStatistics().

#define itkGetStringMacro name   ) 
 

Value:

virtual const char* Get##name () const \
  { \
    return this->m_##name.c_str(); \
  }
Get character string. Creates member Get"name"() (e.g., SetFilename(char *)). The macro assumes that the class member (name) is declared a type std::string.

Definition at line 207 of file itkMacro.h.

#define itkGetVectorMacro name,
type,
count   ) 
 

Value:

virtual type *Get##name () const \
  { \
    return this->m_##name; \
  }
Get vector macro. Returns pointer to type (i.e., array of type). This is for efficiency.

Definition at line 316 of file itkMacro.h.

#define itkLegacy method   )     method
 

Definition at line 584 of file itkMacro.h.

#define itkLegacyBody method,
version   )     itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
 

Definition at line 605 of file itkMacro.h.

Referenced by itk::GrayscaleGrindPeakImageFilter< TInputImage, TOutputImage >::GetNumberOfIterationsUsed(), itk::GrayscaleFillholeImageFilter< TInputImage, TOutputImage >::GetNumberOfIterationsUsed(), and itk::LandmarkBasedTransformInitializer< TTransform, TFixedImage, TMovingImage >::SetFixedImage().

#define itkLegacyReplaceBody method,
version,
replace   )     itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version. Use " #replace " instead.")
 

Definition at line 607 of file itkMacro.h.

#define itkLogMacro x,
 ) 
 

Value:

{         \
  if (this->GetLogger() ) \
    {  \
    this->GetLogger()->Write(::itk::LoggerBase::x, y); \
    }  \
}

Definition at line 544 of file itkMacro.h.

#define itkLogMacroStatic obj,
x,
 ) 
 

Value:

{         \
  if (obj->GetLogger() ) \
    {  \
    obj->GetLogger()->Write(::itk::LoggerBase::x, y); \
    }  \
}

Definition at line 553 of file itkMacro.h.

#define itkNewMacro  ) 
 

Value:

static Pointer New(void) \
{ \
  Pointer smartPtr; \
  x *rawPtr = ::itk::ObjectFactory<x>::Create(); \
  if(rawPtr == NULL) \
    { \
    rawPtr = new x; \
    } \
  smartPtr = rawPtr; \
  rawPtr->UnRegister(); \
  return smartPtr; \
} \
virtual ::itk::LightObject::Pointer CreateAnother(void) const \
{ \
  ::itk::LightObject::Pointer smartPtr; \
  smartPtr = x::New().GetPointer(); \
  return smartPtr; \
}
Define two object creation methods. The first method, New(), creates an object from a class, potentially deferring to a factory. The second method, CreateAnother(), creates an object from an instance, potentially deferring to a factory. This second method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.

These creation methods first try asking the object factory to create an instance, and then default to the standard "new" operator if the factory fails.

These routines assigns the raw pointer to a smart pointer and then call UnRegister() on the rawPtr to compensate for LightObject's constructor initializing an object's reference count to 1 (needed for proper initialization of process objects and data objects cycles).

Definition at line 338 of file itkMacro.h.

#define itkNotUsed  ) 
 

A convenience macro marks variables as not being used by a method, avoiding compile-time warnings.

Definition at line 59 of file itkMacro.h.

#define itkSetClampMacro name,
type,
min,
max   ) 
 

Value:

virtual void Set##name (type _arg) \
  { \
    itkDebugMacro("setting " << #name " to " << _arg ); \
    if (this->m_##name != (_arg<min?min:(_arg>max?max:_arg))) \
      { \
      this->m_##name = (_arg<min?min:(_arg>max?max:_arg)); \
      this->Modified(); \
      } \
  }
Set built-in type where value is constrained between min/max limits. Create member Set"name"() (e.q., SetRadius()). #defines are convienience for clamping open-ended values.

Definition at line 216 of file itkMacro.h.

#define itkSetConstObjectMacro name,
type   ) 
 

Value:

virtual void Set##name (const type* _arg) \
  { \
    itkDebugMacro("setting " << #name " to " << _arg ); \
    if (this->m_##name != _arg) \
      { \
      this->m_##name = _arg; \
      this->Modified(); \
      } \
  }
Set const pointer to object; uses Object reference counting methodology. Creates method Set"name"() (e.g., SetPoints()). Note that using smart pointers requires using real pointers when setting input, but returning smart pointers on output.

Definition at line 258 of file itkMacro.h.

#define itkSetInputMacro name,
type,
number   ) 
 

Value:

virtual void Set##name##Input(const type *_arg) \
  { \
    itkDebugMacro("setting input " #name " to " << _arg); \
    if (_arg != static_cast<type *>(this->ProcessObject::GetInput( number ))) \
      { \
      this->ProcessObject::SetNthInput( number, const_cast<type *>(_arg) ); \
      this->Modified(); \
      } \
  } \
  virtual void SetInput##number(const type *_arg) \
  { \
    itkDebugMacro("setting input " #number " to " << _arg); \
    if (_arg != static_cast<type *>(this->ProcessObject::GetInput( number ))) \
      { \
      this->ProcessObject::SetNthInput( number, const_cast<type *>(_arg) ); \
      this->Modified(); \
      } \
  }
Set an input. This defines the Set"name"Input() method

Definition at line 102 of file itkMacro.h.

#define itkSetMacro name,
type   ) 
 

Value:

virtual void Set##name (const type _arg) \
  { \
    itkDebugMacro("setting " #name " to " << _arg); \
    if (this->m_##name != _arg) \
      { \
      this->m_##name = _arg; \
      this->Modified(); \
      } \
  }
Set built-in type. Creates member Set"name"() (e.g., SetVisibility());

Definition at line 140 of file itkMacro.h.

#define itkSetObjectMacro name,
type   ) 
 

Value:

virtual void Set##name (type* _arg) \
  { \
    itkDebugMacro("setting " << #name " to " << _arg ); \
    if (this->m_##name != _arg) \
      { \
      this->m_##name = _arg; \
      this->Modified(); \
      } \
  }
Set pointer to object; uses Object reference counting methodology. Creates method Set"name"() (e.g., SetPoints()). Note that using smart pointers requires using real pointers when setting input, but returning smart pointers on output.

Definition at line 232 of file itkMacro.h.

#define itkSetStringMacro name   ) 
 

Value:

virtual void Set##name (const char* _arg) \
  { \
    if ( _arg && (_arg == this->m_##name) ) { return;} \
    if (_arg) \
      { \
      this->m_##name = _arg;\
      } \
     else \
      { \
      this->m_##name = ""; \
      } \
    this->Modified(); \
  }
Set character string. Creates member Set"name"() (e.g., SetFilename(char *)). The macro assumes that the class member (name) is declared a type std::string.

Definition at line 187 of file itkMacro.h.

#define itkSetVectorMacro name,
type,
count   ) 
 

Value:

virtual void Set##name(type data[]) \
  { \
    unsigned int i; \
    for (i=0; i<count; i++) { if ( data[i] != this->m_##name[i] ) { break; }} \
    if ( i < count ) \
      { \
      this->Modified(); \
      for (i=0; i<count; i++) { this->m_##name[i] = data[i]; }\
      } \
  }
General set vector macro creates a single method that copies specified number of values into object. Examples: void SetColor(c,3)

Definition at line 301 of file itkMacro.h.

#define itkStaticConstMacro name,
type,
value   )     static const type name = value
 

Macro to initialize static constants. This is used frequently to replace the use of enum's within a class. Some compilers do not allow an enum of one class to be passed as template argument to another class. Other uses of this macro as possible.

This is based (verbatim) on the BOOST_STATIC_CONSTANT macro. The original Boost documentation is below.

BOOST_STATIC_CONSTANT workaround --------------------------------------- // On compilers which don't allow in-class initialization of static integral constant members, we must use enums as a workaround if we want the constants to be available at compile-time. This macro gives us a convenient way to declare such constants.

Definition at line 92 of file itkMacro.h.

#define itkTypeMacro thisClass,
superclass   ) 
 

Value:

virtual const char *GetNameOfClass() const \
        {return #thisClass;}
Macro used to add standard methods to all classes, mainly type information.

Definition at line 395 of file itkMacro.h.

#define itkWarningMacro  ) 
 

Value:

{ if (itk::Object::GetGlobalWarningDisplay()) \
    { ::itk::OStringStream itkmsg; \
      itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \
             << this->GetNameOfClass() << " (" << this << "): " x  \
             << "\n\n"; \
      itk::OutputWindowDisplayWarningText(itkmsg.str().c_str());} \
}
This macro is used to print warning information (i.e., unusual circumstance but not necessarily fatal.) Example usage looks like: itkWarningMacro(<< "this is warning info" << this->SomeVariable);

Definition at line 440 of file itkMacro.h.

Referenced by itk::DicomImageIO::DicomImageIO(), itk::MatchCardinalityImageToImageMetric< TFixedImage, TMovingImage >::GetDerivative(), itk::SegmentationLevelSetImageFilter< TInputImage, TFeatureImage, TOutputPixelType >::GetMaximumIterations(), itk::PointBasedSpatialObject< TDimension >::GetNumberOfPoints(), itk::PointBasedSpatialObject< TDimension >::GetPoint(), itk::RealTimeClock::GetTimestamp(), itk::VectorCurvatureAnisotropicDiffusionImageFilter< TInputImage, TOutputImage >::InitializeIteration(), itk::CurvatureAnisotropicDiffusionImageFilter< TInputImage, TOutputImage >::InitializeIteration(), itk::SegmentationLevelSetImageFilter< TInputImage, TFeatureImage, TOutputPixelType >::SetMaximumIterations(), itk::NarrowBandLevelSetImageFilter< TInputImage, TFeatureImage, TOutputPixelType, Image< TOutputPixelType,::itk::GetImageDimension< TInputImage >::ImageDimension > >::SetMaximumIterations(), and itk::Statistics::ImageToCooccurrenceListAdaptor< TImage >::SetMeasurementVectorSize().


Generated at Thu May 25 00:19:23 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000