summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2018-04-30 20:58:32 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2018-04-30 20:58:32 +0100
commitedb87e7fa08ead2e1e4770fe34282e55c23278ef (patch)
tree1f8e733c1dc5d503c9bada879caac4ba99700b3a
parentUpdate to new PluginMock interface (diff)
downloadslicer-edb87e7fa08ead2e1e4770fe34282e55c23278ef.tar.bz2
slicer-edb87e7fa08ead2e1e4770fe34282e55c23278ef.tar.xz
slicer-edb87e7fa08ead2e1e4770fe34282e55c23278ef.zip
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.
-rw-r--r--slicer/slicer/modelPartsTypes.h46
-rw-r--r--slicer/slicer/modelPartsTypes.impl.h89
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 <Ice/ObjectF.h>
-#include <boost/multi_index_container_fwd.hpp>
-#include <boost/multi_index/sequenced_index_fwd.hpp>
-#include <boost/multi_index/ordered_index_fwd.hpp>
-#include <boost/multi_index/global_fun.hpp>
-#include <boost/multi_index/member.hpp>
-#include <boost/bimap.hpp>
namespace Slicer {
template<typename T>
@@ -147,37 +140,14 @@ namespace Slicer {
template<typename T>
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<HookBase> HookPtr;
template <typename MT, typename MP>
- 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 <typename MT, typename MP>
- class DLL_PRIVATE HookMetadata : public Hook<MT, MP> {
- 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<typename R>
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::member<HookCommon, const std::string, &HookCommon::name>>,
- boost::multi_index::ordered_non_unique<boost::multi_index::global_fun<const HookCommon &, std::string, &ModelPartForComplexBase::hookNameLower>>
- >> Hooks;
+ class DLL_PRIVATE Hooks;
template<typename H, typename ... P>
static void addHook(Hooks &, const P & ...);
@@ -269,7 +233,7 @@ namespace Slicer {
class DLL_PUBLIC ModelPartForEnum : public ModelPartForEnumBase, protected ModelPartModel<T> {
public:
typedef T element_type;
- typedef boost::bimap<T, std::string> 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 <boost/multi_index_container.hpp>
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index/ordered_index.hpp>
+#include <boost/multi_index/global_fun.hpp>
+#include <boost/multi_index/member.hpp>
#include <boost/algorithm/string/case_conv.hpp>
+#include <boost/bimap.hpp>
#define CUSTOMMODELPARTFOR(Type, BaseModelPart, ModelPartType) \
template<> ModelPartPtr ModelPart::CreateFor<Type>() { return std::make_shared<ModelPartType>(nullptr); } \
@@ -316,6 +319,15 @@ namespace Slicer {
// ModelPartForComplex
template<typename T>
+ class ModelPartForComplex<T>::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::member<HookCommon, const std::string, &HookCommon::name>>,
+ boost::multi_index::ordered_non_unique<boost::multi_index::global_fun<const HookCommon &, std::string, &ModelPartForComplexBase::hookNameLower>>>> {
+ };
+
+ template<typename T>
void ModelPartForComplex<T>::OnEachChild(const ChildHandler & ch)
{
for (const auto & h : hooks) {
@@ -369,46 +381,57 @@ namespace Slicer {
}
template<typename T>
- ModelPartForComplex<T>::HookBase::HookBase(const std::string & n) :
- HookCommon(n)
- {
- }
+ class DLL_PRIVATE ModelPartForComplex<T>::HookBase : public HookCommon {
+ public:
+ HookBase(const std::string & n) :
+ HookCommon(n)
+ {
+ }
+ virtual ~HookBase() = default;
- template<typename T>
- const Metadata & ModelPartForComplex<T>::HookBase::GetMetadata() const
- {
- return emptyMetadata;
- }
+ virtual ModelPartPtr Get(T * t) const = 0;
+ virtual const Metadata & GetMetadata() const override
+ {
+ return emptyMetadata;
+ }
+ };
template<typename T>
template<typename MT, typename MP>
- ModelPartForComplex<T>::Hook<MT, MP>::Hook(MT T::* m, const std::string & n) :
- HookBase(n),
- member(m)
- {
- }
+ class DLL_PRIVATE ModelPartForComplex<T>::Hook : public ModelPartForComplex<T>::HookBase {
+ public:
+ Hook(MT T::* m, const std::string & n) :
+ HookBase(n),
+ member(m)
+ {
+ }
- template<typename T>
- template<typename MT, typename MP>
- ModelPartPtr ModelPartForComplex<T>::Hook<MT, MP>::Get(T * t) const
- {
- return std::make_shared<MP>(t ? const_cast<typename std::remove_const<MT>::type *>(&(t->*member)) : NULL);
- }
+ ModelPartPtr Get(T * t) const override
+ {
+ return std::make_shared<MP>(t ? const_cast<typename std::remove_const<MT>::type *>(&(t->*member)) : NULL);
+ }
- template<typename T>
- template<typename MT, typename MP>
- ModelPartForComplex<T>::HookMetadata<MT, MP>::HookMetadata(MT T::* member, const std::string & n, const Metadata & md) :
- Hook<MT, MP>(member, n),
- metadata(md)
- {
- }
+ private:
+ const MT T::* member;
+ };
template<typename T>
template<typename MT, typename MP>
- const Metadata & ModelPartForComplex<T>::HookMetadata<MT, MP>::GetMetadata() const
- {
- return metadata;
- }
+ class DLL_PRIVATE ModelPartForComplex<T>::HookMetadata : public ModelPartForComplex<T>::template Hook<MT, MP> {
+ public:
+ HookMetadata(MT T::* member, const std::string & n, const Metadata & md) :
+ Hook<MT, MP>(member, n),
+ metadata(md)
+ {
+ }
+
+ virtual const Metadata & GetMetadata() const override
+ {
+ return metadata;
+ }
+
+ const Metadata metadata;
+ };
// ModelPartForClass
template<typename T>
@@ -520,6 +543,10 @@ namespace Slicer {
// ModelPartForEnum
template<typename T>
+ class ModelPartForEnum<T>::Enumerations : public boost::bimap<T, std::string> {
+ };
+
+ template<typename T>
ModelPartForEnum<T>::ModelPartForEnum(T * s) :
ModelPartModel<T>(s)
{