Skip to content

Commit

Permalink
STYLE: Add itkInternalGetNameOfClassImplementationMacro macro
Browse files Browse the repository at this point in the history
Used internally by both `itkVirtualGetNameOfClassMacro` and
`itkOverrideGetNameOfClassMacro`.
  • Loading branch information
N-Dekker committed Jan 15, 2024
1 parent 2999b59 commit 2cc371a
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions Modules/Core/Common/include/itkMacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,24 +434,23 @@ namespace itk
#endif


/** Macro's used to add `GetNameOfClass()` member functions to polymorphic ITK classes: `itkVirtualGetNameOfClassMacro`
* adds a virtual `GetNameOfClass()` member function to the class definition, and `itkOverrideGetNameOfClassMacro` adds
* a `GetNameOfClass()` override. */
#define itkVirtualGetNameOfClassMacro(thisClass) \
virtual const char * GetNameOfClass() const \
// Internal macro (not part of the public ITK API), used to implement `GetNameOfClass()` member functions.
#define itkInternalGetNameOfClassImplementationMacro(thisClass) \
{ \
static_assert(std::is_same_v<thisClass, std::remove_const_t<std::remove_reference_t<decltype(*this)>>>); \
return #thisClass; \
} \
ITK_MACROEND_NOOP_STATEMENT

#define itkOverrideGetNameOfClassMacro(thisClass) \
const char * GetNameOfClass() const override \
{ \
static_assert(std::is_same_v<thisClass, std::remove_const_t<std::remove_reference_t<decltype(*this)>>>); \
return #thisClass; \
} \
ITK_MACROEND_NOOP_STATEMENT

/** Macro's used to add `GetNameOfClass()` member functions to polymorphic ITK classes: `itkVirtualGetNameOfClassMacro`
* adds a virtual `GetNameOfClass()` member function to the class definition, and `itkOverrideGetNameOfClassMacro` adds
* a `GetNameOfClass()` override. */
#define itkVirtualGetNameOfClassMacro(thisClass) \
virtual const char * GetNameOfClass() const itkInternalGetNameOfClassImplementationMacro(thisClass)

#define itkOverrideGetNameOfClassMacro(thisClass) \
const char * GetNameOfClass() const override itkInternalGetNameOfClassImplementationMacro(thisClass)

#ifdef ITK_FUTURE_LEGACY_REMOVE
# define itkTypeMacro(thisClass, superclass) \
Expand Down

0 comments on commit 2cc371a

Please sign in to comment.