From 34557918d0600b1babc6f95fcd39cd2901278591 Mon Sep 17 00:00:00 2001 From: Floris Berendsen <floris.berendsen@gmail.com> Date: Mon, 11 Jan 2016 13:35:07 +0100 Subject: [PATCH] ENH: static assert if Component developer forgot to implement interfacetraits. --- .../ComponentInterface/include/InterfaceTraits.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Modules/Core/ComponentInterface/include/InterfaceTraits.h b/Modules/Core/ComponentInterface/include/InterfaceTraits.h index 0333755f..c0bd7e9b 100644 --- a/Modules/Core/ComponentInterface/include/InterfaceTraits.h +++ b/Modules/Core/ComponentInterface/include/InterfaceTraits.h @@ -2,7 +2,7 @@ #define InterfaceTraits_h #include "Interfaces.h" - +#include "itkMacro.h" namespace selx { // Traits to get printable interface name @@ -12,7 +12,8 @@ struct InterfaceName { static const char* Get() { - //static_assert(false, "Please implement a template specialization for the appropriate InterfaceName"); + static_assert(false, "Please implement a template specialization for the appropriate InterfaceName"); + itkExceptionMacro("Please implement a template specialization for the appropriate InterfaceName"); return typeid(T).name(); } }; @@ -62,7 +63,14 @@ struct InterfaceName < TransformedImageInterface > } }; - +template <> +struct InterfaceName < itkProcessObjectInterface > +{ + static const char* Get() + { + return "itkProcessObjectInterface"; + } +}; // partial specialization of InterfaceName template<template<typename> class TT, typename T1> -- GitLab