summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slicer/slicer/modelParts.h13
-rw-r--r--slicer/slicer/modelPartsTypes.cpp39
-rw-r--r--slicer/slicer/modelPartsTypes.h14
-rw-r--r--slicer/slicer/modelPartsTypes.impl.h37
4 files changed, 59 insertions, 44 deletions
diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h
index 733e441..8cf3bc5 100644
--- a/slicer/slicer/modelParts.h
+++ b/slicer/slicer/modelParts.h
@@ -181,24 +181,15 @@ namespace Slicer {
class DLL_PUBLIC ModelPartForRootBase : public ModelPart {
public:
- };
-
- template<typename T>
- class ModelPartForRoot : public ModelPartForRootBase {
- public:
- ModelPartForRoot(T & o);
+ ModelPartForRootBase(ModelPartPtr mp);
+ virtual const std::string & GetRootName() const = 0;
virtual ChildRefPtr GetAnonChildRef(const HookFilter &) override;
virtual ChildRefPtr GetChildRef(const std::string & name, const HookFilter &) override;
virtual void OnEachChild(const ChildHandler & ch) override;
- virtual bool HasValue() const override;
virtual ModelPartType GetType() const override;
virtual bool IsOptional() const override;
- static const std::string rootName;
-
- private:
- T * ModelObject;
ModelPartPtr mp;
};
}
diff --git a/slicer/slicer/modelPartsTypes.cpp b/slicer/slicer/modelPartsTypes.cpp
index f518f61..bc3810c 100644
--- a/slicer/slicer/modelPartsTypes.cpp
+++ b/slicer/slicer/modelPartsTypes.cpp
@@ -46,6 +46,45 @@ namespace Slicer {
template class Slicer::ModelPartForRoot<IceUtil::Optional<Ice::Int>>;
template class Slicer::ModelPartForRoot<IceUtil::Optional<Ice::Long>>;
+ // ModelPartForRootBase
+ ModelPartForRootBase::ModelPartForRootBase(ModelPartPtr m) :
+ mp(m)
+ {
+ }
+
+ ChildRefPtr
+ ModelPartForRootBase::GetAnonChildRef(const HookFilter &)
+ {
+ mp->Create();
+ return new ImplicitChildRef(mp);
+ }
+
+ ChildRefPtr
+ ModelPartForRootBase::GetChildRef(const std::string & name, const HookFilter & hf)
+ {
+ if (name != GetRootName()) {
+ throw IncorrectElementName(name);
+ }
+ return GetAnonChildRef(hf);
+ }
+
+ void ModelPartForRootBase::OnEachChild(const ChildHandler & ch)
+ {
+ ch(GetRootName(), mp, NULL);
+ }
+
+ ModelPartType
+ ModelPartForRootBase::GetType() const
+ {
+ return mp->GetType();
+ }
+
+ bool
+ ModelPartForRootBase::IsOptional() const
+ {
+ return mp->IsOptional();
+ }
+
void ModelPartForSimpleBase::OnEachChild(const ChildHandler &) { }
ChildRefPtr ModelPartForSimpleBase::GetAnonChildRef(const HookFilter &) { return NULL; }
ChildRefPtr ModelPartForSimpleBase::GetChildRef(const std::string &, const HookFilter &) { return NULL; }
diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h
index ac6ed73..88ee0bd 100644
--- a/slicer/slicer/modelPartsTypes.h
+++ b/slicer/slicer/modelPartsTypes.h
@@ -4,6 +4,20 @@
#include "modelParts.h"
namespace Slicer {
+ template<typename T>
+ class DLL_PUBLIC ModelPartForRoot : public ModelPartForRootBase {
+ public:
+ ModelPartForRoot(T & o);
+
+ const std::string & GetRootName() const override;
+ virtual bool HasValue() const override;
+
+ static const std::string rootName;
+
+ private:
+ T * ModelObject;
+ };
+
class DLL_PUBLIC ModelPartForSimpleBase : public ModelPart {
public:
virtual void OnEachChild(const ChildHandler &) override;
diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h
index 071efcf..2de1780 100644
--- a/slicer/slicer/modelPartsTypes.impl.h
+++ b/slicer/slicer/modelPartsTypes.impl.h
@@ -15,32 +15,15 @@ namespace Slicer {
// ModelPartForRoot
template<typename T>
ModelPartForRoot<T>::ModelPartForRoot(T & o) :
- ModelObject(&o),
- mp(ModelPart::CreateFor(o))
+ ModelPartForRootBase(ModelPart::CreateFor(o)),
+ ModelObject(&o)
{
}
template<typename T>
- ChildRefPtr ModelPartForRoot<T>::GetAnonChildRef(const HookFilter &)
+ const std::string & ModelPartForRoot<T>::GetRootName() const
{
- mp->Create();
- return new ImplicitChildRef(mp);
- }
-
- template<typename T>
- ChildRefPtr ModelPartForRoot<T>::GetChildRef(const std::string & name, const HookFilter &)
- {
- if (name != rootName) {
- throw IncorrectElementName(name);
- }
- mp->Create();
- return new ImplicitChildRef(mp);
- }
-
- template<typename T>
- void ModelPartForRoot<T>::OnEachChild(const ChildHandler & ch)
- {
- ch(rootName, mp, NULL);
+ return rootName;
}
template<typename T>
@@ -49,18 +32,6 @@ namespace Slicer {
return ModelObject && mp->HasValue();
}
- template<typename T>
- ModelPartType ModelPartForRoot<T>::GetType() const
- {
- return mp->GetType();
- }
-
- template<typename T>
- bool ModelPartForRoot<T>::IsOptional() const
- {
- return mp->IsOptional();
- }
-
// ModelPartForSimple
template<typename T>
ModelPartForSimple<T>::ModelPartForSimple(T & h) :