From edb87e7fa08ead2e1e4770fe34282e55c23278ef Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 30 Apr 2018 20:58:32 +0100 Subject: External model part classes Remove the need for the internal workings of complex classes and enumerations to be declared in the types header. All moved to the types implementation header. --- slicer/slicer/modelPartsTypes.h | 46 ++----------------- slicer/slicer/modelPartsTypes.impl.h | 89 +++++++++++++++++++++++------------- 2 files changed, 63 insertions(+), 72 deletions(-) diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h index 45ba1f6..ee5a083 100644 --- a/slicer/slicer/modelPartsTypes.h +++ b/slicer/slicer/modelPartsTypes.h @@ -2,13 +2,6 @@ #define SLICER_MODELPARTSTYPES_H #include "modelParts.h" -#include -#include -#include -#include -#include -#include -#include namespace Slicer { template @@ -147,37 +140,14 @@ namespace Slicer { template class DLL_PUBLIC ModelPartForComplex : public ModelPartForComplexBase { public: - class DLL_PRIVATE HookBase : public HookCommon { - public: - HookBase(const std::string & n); - virtual ~HookBase() = default; - - virtual ModelPartPtr Get(T * t) const = 0; - virtual const Metadata & GetMetadata() const override; - }; + class DLL_PRIVATE HookBase; typedef std::unique_ptr HookPtr; template - class DLL_PRIVATE Hook : public HookBase { - public: - Hook(MT T::* m, const std::string & n); - - ModelPartPtr Get(T * t) const override; - - private: - const MT T::* member; - }; + class DLL_PRIVATE Hook; template - class DLL_PRIVATE HookMetadata : public Hook { - public: - HookMetadata(MT T::* member, const std::string & n, const Metadata & md); - - virtual const Metadata & GetMetadata() const override; - - const Metadata metadata; - }; - + class DLL_PRIVATE HookMetadata; virtual void OnEachChild(const ChildHandler & ch) override; @@ -192,13 +162,7 @@ namespace Slicer { template DLL_PRIVATE ChildRef GetChildRefFromRange(const R & range, const HookFilter & flt); - typedef boost::multi_index_container< - HookPtr, - boost::multi_index::indexed_by< - boost::multi_index::sequenced<>, - boost::multi_index::ordered_non_unique>, - boost::multi_index::ordered_non_unique> - >> Hooks; + class DLL_PRIVATE Hooks; template static void addHook(Hooks &, const P & ...); @@ -269,7 +233,7 @@ namespace Slicer { class DLL_PUBLIC ModelPartForEnum : public ModelPartForEnumBase, protected ModelPartModel { public: typedef T element_type; - typedef boost::bimap Enumerations; + class DLL_PRIVATE Enumerations; ModelPartForEnum(T * s); diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h index 408327d..f8e2ba6 100644 --- a/slicer/slicer/modelPartsTypes.impl.h +++ b/slicer/slicer/modelPartsTypes.impl.h @@ -8,7 +8,10 @@ #include #include #include +#include +#include #include +#include #define CUSTOMMODELPARTFOR(Type, BaseModelPart, ModelPartType) \ template<> ModelPartPtr ModelPart::CreateFor() { return std::make_shared(nullptr); } \ @@ -315,6 +318,15 @@ namespace Slicer { } // ModelPartForComplex + template + class ModelPartForComplex::Hooks : public boost::multi_index_container< + HookPtr, + boost::multi_index::indexed_by< + boost::multi_index::sequenced<>, + boost::multi_index::ordered_non_unique>, + boost::multi_index::ordered_non_unique>>> { + }; + template void ModelPartForComplex::OnEachChild(const ChildHandler & ch) { @@ -369,46 +381,57 @@ namespace Slicer { } template - ModelPartForComplex::HookBase::HookBase(const std::string & n) : - HookCommon(n) - { - } + class DLL_PRIVATE ModelPartForComplex::HookBase : public HookCommon { + public: + HookBase(const std::string & n) : + HookCommon(n) + { + } + virtual ~HookBase() = default; - template - const Metadata & ModelPartForComplex::HookBase::GetMetadata() const - { - return emptyMetadata; - } + virtual ModelPartPtr Get(T * t) const = 0; + virtual const Metadata & GetMetadata() const override + { + return emptyMetadata; + } + }; template template - ModelPartForComplex::Hook::Hook(MT T::* m, const std::string & n) : - HookBase(n), - member(m) - { - } + class DLL_PRIVATE ModelPartForComplex::Hook : public ModelPartForComplex::HookBase { + public: + Hook(MT T::* m, const std::string & n) : + HookBase(n), + member(m) + { + } - template - template - ModelPartPtr ModelPartForComplex::Hook::Get(T * t) const - { - return std::make_shared(t ? const_cast::type *>(&(t->*member)) : NULL); - } + ModelPartPtr Get(T * t) const override + { + return std::make_shared(t ? const_cast::type *>(&(t->*member)) : NULL); + } - template - template - ModelPartForComplex::HookMetadata::HookMetadata(MT T::* member, const std::string & n, const Metadata & md) : - Hook(member, n), - metadata(md) - { - } + private: + const MT T::* member; + }; template template - const Metadata & ModelPartForComplex::HookMetadata::GetMetadata() const - { - return metadata; - } + class DLL_PRIVATE ModelPartForComplex::HookMetadata : public ModelPartForComplex::template Hook { + public: + HookMetadata(MT T::* member, const std::string & n, const Metadata & md) : + Hook(member, n), + metadata(md) + { + } + + virtual const Metadata & GetMetadata() const override + { + return metadata; + } + + const Metadata metadata; + }; // ModelPartForClass template @@ -519,6 +542,10 @@ namespace Slicer { } // ModelPartForEnum + template + class ModelPartForEnum::Enumerations : public boost::bimap { + }; + template ModelPartForEnum::ModelPartForEnum(T * s) : ModelPartModel(s) -- cgit v1.2.3