From 069a93016c187f6072374e7976e55d0e02ddd779 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 24 Sep 2023 14:45:38 +0100 Subject: Single thrower of AbstractClassException --- slicer/slicer/modelPartsTypes.cpp | 6 ++++++ slicer/slicer/modelPartsTypes.h | 1 + slicer/slicer/modelPartsTypes.impl.h | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/slicer/slicer/modelPartsTypes.cpp b/slicer/slicer/modelPartsTypes.cpp index 04fc859..e65d721 100644 --- a/slicer/slicer/modelPartsTypes.cpp +++ b/slicer/slicer/modelPartsTypes.cpp @@ -80,6 +80,12 @@ namespace Slicer { throw IncorrectType(name, demangle(target.name())); } + [[noreturn]] void + ModelPartForComplexBase::throwAbstractClassException(const std::type_info & target) + { + throw AbstractClassException(demangle(target.name())); + } + #define Roots(Type, Name, NameLen) \ template<> CONSTSTR(NameLen) Slicer::ModelPartForRoot::rootName {#Name}; \ template<> \ diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h index c81e014..e73b99c 100644 --- a/slicer/slicer/modelPartsTypes.h +++ b/slicer/slicer/modelPartsTypes.h @@ -148,6 +148,7 @@ namespace Slicer { static const std::string & ToExchangeTypeName(const std::string &); static std::string_view ToModelTypeName(const std::string &); [[noreturn]] static void throwIncorrectType(const std::string & name, const std::type_info & target); + [[noreturn]] static void throwAbstractClassException(const std::type_info & target); }; template class Hooks; diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h index 692437e..b1f0df8 100644 --- a/slicer/slicer/modelPartsTypes.impl.h +++ b/slicer/slicer/modelPartsTypes.impl.h @@ -429,7 +429,7 @@ namespace Slicer { { BOOST_ASSERT(this->Model); if constexpr (std::is_abstract_v) { - throw AbstractClassException(ModelPartForComplexBase::demangle(typeid(T).name())); + ModelPartForComplexBase::throwAbstractClassException(typeid(T)); } else { *this->Model = std::make_shared(); -- cgit v1.2.3