go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
elxMacro.h File Reference
#include "itkWin32Header.h"
#include "itkMacro.h"
Include dependency graph for elxMacro.h:

Go to the source code of this file.

Macros

#define ELASTIXLIB_API
 
#define elxClassNameMacro(_name)
 
#define elxDeclarePureVirtualGetSelfMacro(type)
 
#define elxInstallMacro(_classname)
 
#define elxout   ::xl::xout["standard"]
 
#define elxOverrideGetSelfMacro
 

Macro Definition Documentation

◆ ELASTIXLIB_API

#define ELASTIXLIB_API

Definition at line 169 of file elxMacro.h.

◆ elxClassNameMacro

#define elxClassNameMacro ( _name)
Value:
static const char * elxGetClassNameStatic() { return _name; } \
const char * elxGetClassName() const override { return _name; }

elxClassNameMacro(_name)

Example of usage:

class MyMetric { public: elxClassNameMacro("MyFirstMetric"); }

This macro defines two functions.

static const char * elxGetClassNameStatic(){return _name;} const char * elxGetClassName() const override { return _name; }

Use this macro in every component that will be installed in the ComponentDatabase, using "elxInstallMacro".

Definition at line 123 of file elxMacro.h.

◆ elxDeclarePureVirtualGetSelfMacro

#define elxDeclarePureVirtualGetSelfMacro ( type)
Value:
virtual const type & GetSelf() const override = 0; \
virtual type & GetSelf() override = 0

Declares a pair of pure virtual member functions (overloaded for const and non-const) to get a reference to itself, of the specified type.

Definition at line 130 of file elxMacro.h.

◆ elxInstallMacro

#define elxInstallMacro ( _classname)
Value:
extern "C" int _classname##InstallComponent(::elastix::ComponentDatabase * _cdb) \
{ \
return ::elastix::ComponentInstaller<::elastix::_classname>::DO(_cdb); \
}
The ComponentDatabase class is a class that stores the New() functions of all components.

This include is only used to get rid of a MSVS compiler warning when using std::copy. The warning is like: 'conversion' conversion from 'type1' to 'type2', possible loss of data To solve it ITK recommends to include itkMacro.h before <algorithm> or any other stl header. In elastix we try to make sure that elxIncludes.h is included before anything else, which includes elxMacro.h, which now includes itkWin32Header.h. Macro for installing support new components (like a new metric, interpolator, or transform). Must be invoked in the .cxx file of the component, after declaration of the class.

Example of usage:

// elxMyMetric.h //
#include "elxMetricBase.h"
#include "itkMattesMutualInformationImageToImageMetric.h"
namespace elastix {
template <class TElastix>
class ITK_TEMPLATE_EXPORT MyMetric : public MetricBase<TElastix>,
public itk::MattesMutualInformationImageToImageMetric
< MetricBase<TElastix>::FixedImageType
MetricBase<TElastix>::MovingImageType >
{
using Self = MyMetric;
itkNewMacro( Self ); //needed for the elxInstallMacro
elxClassNameMacro("MattesMutualInformation"); //also needed
.......
};
} // end namespace elastix
#define elxClassNameMacro(_name)
Definition elxMacro.h:123
// elxMyMetric.hxx //
// Definitions of the methods of the MyMetric class template
// elxMyMetric.cxx //
#include elxMyMetric.h
elxInstallMacro(MyMetric);
// CMakeLists.txt //
ADD_ELXCOMPONENT( MyMetric
elxMyMetric.h
elxMyMetric.hxx
elxMyMetric.cxx
[<any other source files needed>] )
#define elxInstallMacro(_classname)
Definition elxMacro.h:97

The class to be installed should inherit from the appropriate base class. (elx::MetricBase, elx::TransformBase etc,) and from a specific itk object.

IMPORTANT: only one template argument <class TElastix> is allowed. Not more, not less.

Details: a function "int _classname##InstallComponent( _cdb )" is defined. In this function a ComponentInstaller template is instantiated. It contains the ElastixTypedef<VIndex>, and recursive function DO(cdb). DO installs the component for all defined ElastixTypedefs (so for all supported image types).

Definition at line 97 of file elxMacro.h.

◆ elxout

#define elxout   ::xl::xout["standard"]

elxout

This macro replaces 'elxout' by 'xl::xout["standard"]'. This simplifies writing messages to screen and logfile.

NB: for error and warning messages, for writing to the transformparameterfile etc. do not use elxout, but xl::xout["{error, warning, etc}"].

Definition at line 155 of file elxMacro.h.

◆ elxOverrideGetSelfMacro

#define elxOverrideGetSelfMacro
Value:
auto GetSelf() const->decltype(*this) override { return *this; } \
auto GetSelf()->decltype(*this) override { return *this; } \
static void GetSelf(const void *) = delete

Defines a pair of overrides of GetSelf() (overloaded for const and non-const), which return a reference to itself. Declares a deleted static member function overload, just to allow macro calls to end with a semicolon.

Definition at line 138 of file elxMacro.h.



Generated on 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo