From 5cf242d9e474f4b5b598b48fb86e696856802fa6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 6 Oct 2016 22:36:51 +0100 Subject: Detemplate GetSubclassModelPart a bit --- slicer/slicer/modelPartsTypes.cpp | 8 ++++++++ slicer/slicer/modelPartsTypes.h | 2 ++ slicer/slicer/modelPartsTypes.impl.h | 6 +----- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/slicer/slicer/modelPartsTypes.cpp b/slicer/slicer/modelPartsTypes.cpp index e5744df..05e30cd 100644 --- a/slicer/slicer/modelPartsTypes.cpp +++ b/slicer/slicer/modelPartsTypes.cpp @@ -97,6 +97,14 @@ namespace Slicer { Slicer::classNameMap()->left.erase(className); } } + ModelPartPtr ModelPartForComplexBase::getSubclassModelPart(const std::string & name, void * m) + { + auto ref = classRefMap()->find(ModelPart::ToModelTypeName(name)); + if (ref == classRefMap()->end()) { + throw UnknownType(name); + } + return ref->second(m); + } void ModelPartForEnumBase::OnEachChild(const ChildHandler &) { } ChildRefPtr ModelPartForEnumBase::GetAnonChildRef(const HookFilter &) { return NULL; } diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h index 483d8a7..d19f03d 100644 --- a/slicer/slicer/modelPartsTypes.h +++ b/slicer/slicer/modelPartsTypes.h @@ -92,6 +92,8 @@ namespace Slicer { static const ModelPartType type; protected: + ModelPartPtr getSubclassModelPart(const std::string & name, void * m); + static void registerClass(const std::string & className, const TypeId & typeName, const ClassRef &); static void unregisterClass(const std::string & className, const TypeId & typeName); }; diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h index 658e95b..401c3ed 100644 --- a/slicer/slicer/modelPartsTypes.impl.h +++ b/slicer/slicer/modelPartsTypes.impl.h @@ -279,11 +279,7 @@ namespace Slicer { template ModelPartPtr ModelPartForClass::GetSubclassModelPart(const std::string & name) { - auto ref = classRefMap()->find(ModelPart::ToModelTypeName(name)); - if (ref == classRefMap()->end()) { - throw UnknownType(name); - } - return ref->second(&this->Model); + return ModelPartForComplexBase::getSubclassModelPart(name, &this->Model); } template -- cgit v1.2.3