summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slicer/slicer/modelParts.h3
-rw-r--r--slicer/slicer/modelPartsTypes.cpp44
-rw-r--r--slicer/slicer/modelPartsTypes.h38
-rw-r--r--slicer/slicer/parser.cpp30
4 files changed, 59 insertions, 56 deletions
diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h
index ea563c1..3533cc7 100644
--- a/slicer/slicer/modelParts.h
+++ b/slicer/slicer/modelParts.h
@@ -203,10 +203,11 @@ namespace Slicer {
virtual ModelPartType GetType() const override;
virtual bool IsOptional() const override;
+ static const std::string rootName;
+
private:
T * ModelObject;
ModelPartPtr mp;
- static std::string rootName;
};
}
diff --git a/slicer/slicer/modelPartsTypes.cpp b/slicer/slicer/modelPartsTypes.cpp
index 4540060..f518f61 100644
--- a/slicer/slicer/modelPartsTypes.cpp
+++ b/slicer/slicer/modelPartsTypes.cpp
@@ -10,23 +10,23 @@ namespace Slicer {
MODELPARTFOR(Ice::Int, ModelPartForSimple);
MODELPARTFOR(Ice::Long, ModelPartForSimple);
- template<> std::string Slicer::ModelPartForRoot<std::string>::rootName = "String";
- template<> std::string Slicer::ModelPartForRoot<bool>::rootName = "Boolean";
- template<> std::string Slicer::ModelPartForRoot<Ice::Float>::rootName = "Float";
- template<> std::string Slicer::ModelPartForRoot<Ice::Double>::rootName = "Double";
- template<> std::string Slicer::ModelPartForRoot<Ice::Byte>::rootName = "Byte";
- template<> std::string Slicer::ModelPartForRoot<Ice::Short>::rootName = "Short";
- template<> std::string Slicer::ModelPartForRoot<Ice::Int>::rootName = "Int";
- template<> std::string Slicer::ModelPartForRoot<Ice::Long>::rootName = "Long";
+ template<> const std::string Slicer::ModelPartForRoot<std::string>::rootName = "String";
+ template<> const std::string Slicer::ModelPartForRoot<bool>::rootName = "Boolean";
+ template<> const std::string Slicer::ModelPartForRoot<Ice::Float>::rootName = "Float";
+ template<> const std::string Slicer::ModelPartForRoot<Ice::Double>::rootName = "Double";
+ template<> const std::string Slicer::ModelPartForRoot<Ice::Byte>::rootName = "Byte";
+ template<> const std::string Slicer::ModelPartForRoot<Ice::Short>::rootName = "Short";
+ template<> const std::string Slicer::ModelPartForRoot<Ice::Int>::rootName = "Int";
+ template<> const std::string Slicer::ModelPartForRoot<Ice::Long>::rootName = "Long";
- template<> std::string Slicer::ModelPartForRoot<IceUtil::Optional<std::string>>::rootName = "OptionalString";
- template<> std::string Slicer::ModelPartForRoot<IceUtil::Optional<bool>>::rootName = "OptionalBoolean";
- template<> std::string Slicer::ModelPartForRoot<IceUtil::Optional<Ice::Float>>::rootName = "OptionalFloat";
- template<> std::string Slicer::ModelPartForRoot<IceUtil::Optional<Ice::Double>>::rootName = "OptionalDouble";
- template<> std::string Slicer::ModelPartForRoot<IceUtil::Optional<Ice::Byte>>::rootName = "OptionalByte";
- template<> std::string Slicer::ModelPartForRoot<IceUtil::Optional<Ice::Short>>::rootName = "OptionalShort";
- template<> std::string Slicer::ModelPartForRoot<IceUtil::Optional<Ice::Int>>::rootName = "OptionalInt";
- template<> std::string Slicer::ModelPartForRoot<IceUtil::Optional<Ice::Long>>::rootName = "OptionalLong";
+ template<> const std::string Slicer::ModelPartForRoot<IceUtil::Optional<std::string>>::rootName = "OptionalString";
+ template<> const std::string Slicer::ModelPartForRoot<IceUtil::Optional<bool>>::rootName = "OptionalBoolean";
+ template<> const std::string Slicer::ModelPartForRoot<IceUtil::Optional<Ice::Float>>::rootName = "OptionalFloat";
+ template<> const std::string Slicer::ModelPartForRoot<IceUtil::Optional<Ice::Double>>::rootName = "OptionalDouble";
+ template<> const std::string Slicer::ModelPartForRoot<IceUtil::Optional<Ice::Byte>>::rootName = "OptionalByte";
+ template<> const std::string Slicer::ModelPartForRoot<IceUtil::Optional<Ice::Short>>::rootName = "OptionalShort";
+ template<> const std::string Slicer::ModelPartForRoot<IceUtil::Optional<Ice::Int>>::rootName = "OptionalInt";
+ template<> const std::string Slicer::ModelPartForRoot<IceUtil::Optional<Ice::Long>>::rootName = "OptionalLong";
template class Slicer::ModelPartForRoot<std::string>;
template class Slicer::ModelPartForRoot<bool>;
@@ -51,31 +51,31 @@ namespace Slicer {
ChildRefPtr ModelPartForSimpleBase::GetChildRef(const std::string &, const HookFilter &) { return NULL; }
bool ModelPartForSimpleBase::HasValue() const { return true; }
ModelPartType ModelPartForSimpleBase::GetType() const { return type; }
- ModelPartType ModelPartForSimpleBase::type = mpt_Simple;
+ const ModelPartType ModelPartForSimpleBase::type = mpt_Simple;
void ModelPartForConvertedBase::OnEachChild(const ChildHandler &) { }
ChildRefPtr ModelPartForConvertedBase::GetAnonChildRef(const HookFilter &) { return NULL; }
ChildRefPtr ModelPartForConvertedBase::GetChildRef(const std::string &, const HookFilter &) { return NULL; }
bool ModelPartForConvertedBase::HasValue() const { return true; }
ModelPartType ModelPartForConvertedBase::GetType() const { return type; }
- ModelPartType ModelPartForConvertedBase::type = mpt_Simple;
+ const ModelPartType ModelPartForConvertedBase::type = mpt_Simple;
ModelPartType ModelPartForComplexBase::GetType() const { return type; }
- ModelPartType ModelPartForComplexBase::type = mpt_Complex;
+ const ModelPartType ModelPartForComplexBase::type = mpt_Complex;
void ModelPartForEnumBase::OnEachChild(const ChildHandler &) { }
ChildRefPtr ModelPartForEnumBase::GetAnonChildRef(const HookFilter &) { return NULL; }
ChildRefPtr ModelPartForEnumBase::GetChildRef(const std::string &, const HookFilter &) { return NULL; }
bool ModelPartForEnumBase::HasValue() const { return true; }
ModelPartType ModelPartForEnumBase::GetType() const { return type; }
- ModelPartType ModelPartForEnumBase::type = mpt_Simple;
+ const ModelPartType ModelPartForEnumBase::type = mpt_Simple;
bool ModelPartForSequenceBase::HasValue() const { return true; }
ModelPartType ModelPartForSequenceBase::GetType() const { return type; }
- ModelPartType ModelPartForSequenceBase::type = mpt_Sequence;
+ const ModelPartType ModelPartForSequenceBase::type = mpt_Sequence;
bool ModelPartForDictionaryBase::HasValue() const { return true; }
ModelPartType ModelPartForDictionaryBase::GetType() const { return type; }
- ModelPartType ModelPartForDictionaryBase::type = mpt_Dictionary;
+ const ModelPartType ModelPartForDictionaryBase::type = mpt_Dictionary;
}
diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h
index e3f56a4..c2e8cfe 100644
--- a/slicer/slicer/modelPartsTypes.h
+++ b/slicer/slicer/modelPartsTypes.h
@@ -11,7 +11,7 @@ namespace Slicer {
virtual ChildRefPtr GetChildRef(const std::string &, const HookFilter &) override;
virtual bool HasValue() const override;
virtual ModelPartType GetType() const override;
- static ModelPartType type;
+ static const ModelPartType type;
};
template<typename T>
@@ -35,7 +35,7 @@ namespace Slicer {
virtual ChildRefPtr GetChildRef(const std::string &, const HookFilter &) override;
virtual bool HasValue() const override;
virtual ModelPartType GetType() const override;
- static ModelPartType type;
+ static const ModelPartType type;
};
template<typename T, typename M, T M::* MV>
@@ -80,7 +80,7 @@ namespace Slicer {
class DLL_PUBLIC ModelPartForComplexBase : public ModelPart {
public:
virtual ModelPartType GetType() const override;
- static ModelPartType type;
+ static const ModelPartType type;
};
template<typename T>
@@ -98,8 +98,7 @@ namespace Slicer {
public:
virtual const Metadata & GetMetadata() const override { return metadata; }
- private:
- static Metadata metadata;
+ static const Metadata metadata;
};
template <typename MT, typename CT, MT CT::*M, typename MP, typename Base = HookMetadata<MT, CT, M>>
@@ -136,9 +135,8 @@ namespace Slicer {
typedef std::vector<HookPtr> Hooks;
- private:
- static Hooks hooks;
- static Metadata metadata;
+ static const Hooks hooks;
+ static const Metadata metadata;
};
template<typename T>
@@ -160,9 +158,10 @@ namespace Slicer {
virtual IceUtil::Optional<std::string> GetTypeIdProperty() const override;
+ static const std::string typeIdProperty;
+
private:
T & ModelObject;
- static std::string typeIdProperty;
};
template<typename T>
@@ -187,7 +186,7 @@ namespace Slicer {
ChildRefPtr GetChildRef(const std::string &, const HookFilter &) override;
virtual bool HasValue() const override;
virtual ModelPartType GetType() const override;
- static ModelPartType type;
+ static const ModelPartType type;
};
template<typename T>
@@ -204,17 +203,18 @@ namespace Slicer {
virtual void GetValue(ValueTargetPtr s) override;
+ static const Metadata metadata;
+ static const Enumerations enumerations;
+
private:
T & modelPart;
- static Metadata metadata;
- static Enumerations enumerations;
};
class DLL_PUBLIC ModelPartForSequenceBase : public ModelPart {
public:
virtual bool HasValue() const override;
virtual ModelPartType GetType() const override;
- static ModelPartType type;
+ static const ModelPartType type;
};
template<typename T>
@@ -232,12 +232,13 @@ namespace Slicer {
virtual const Metadata & GetMetadata() const override;
+ static const Metadata metadata;
+ static const std::string elementName;
+
private:
ModelPartPtr elementModelPart(typename T::value_type &) const;
T & sequence;
- static std::string elementName;
- static Metadata metadata;
};
template<typename T>
@@ -257,7 +258,7 @@ namespace Slicer {
public:
virtual bool HasValue() const override;
virtual ModelPartType GetType() const override;
- static ModelPartType type;
+ static const ModelPartType type;
};
template<typename T>
@@ -275,10 +276,11 @@ namespace Slicer {
virtual const Metadata & GetMetadata() const override;
+ static const Metadata metadata;
+ static const std::string pairName;
+
private:
T & dictionary;
- static std::string pairName;
- static Metadata metadata;
};
}
diff --git a/slicer/slicer/parser.cpp b/slicer/slicer/parser.cpp
index 7e795be..6a5019b 100644
--- a/slicer/slicer/parser.cpp
+++ b/slicer/slicer/parser.cpp
@@ -157,10 +157,10 @@ namespace Slicer {
Slicer::defineRootName(const std::string & type, const std::string & name) const
{
fprintbf(cpp, "template<>\n");
- fprintbf(cpp, "std::string ModelPartForRoot< %s >::rootName(\"%s\");\n\n",
+ fprintbf(cpp, "const std::string ModelPartForRoot< %s >::rootName(\"%s\");\n\n",
type, name);
fprintbf(cpp, "template<>\n");
- fprintbf(cpp, "std::string ModelPartForRoot< IceUtil::Optional< %s > >::rootName(\"Optional%s\");\n\n",
+ fprintbf(cpp, "const std::string ModelPartForRoot< IceUtil::Optional< %s > >::rootName(\"Optional%s\");\n\n",
type, name);
fprintbf(cpp, "template class ModelPartForRoot< %s >;\n\n", type);
@@ -183,7 +183,7 @@ namespace Slicer {
fprintbf(cpp, "template<>\n");
auto typeId = metaDataValue("slicer:typeid:", c->getMetaData());
- fprintbf(cpp, "std::string ModelPartForClass< %s >::typeIdProperty(\"%s\");\n\n",
+ fprintbf(cpp, "const std::string ModelPartForClass< %s >::typeIdProperty(\"%s\");\n\n",
typeToString(decl),
typeId ? *typeId : "slicer-typeid");
@@ -219,7 +219,7 @@ namespace Slicer {
fprintbf(cpp, "\treturn (id == \"%s\") ? TypeId() : ModelPart::ToExchangeTypeName(id);\n}\n\n",
c->scoped());
- fprintbf(cpp, "template<>\nMetadata ModelPartForComplex< %s >::metadata ",
+ fprintbf(cpp, "template<>\nconst Metadata ModelPartForComplex< %s >::metadata ",
c->scoped());
copyMetadata(c->getMetaData());
@@ -246,7 +246,7 @@ namespace Slicer {
auto name = metaDataValue("slicer:root:", c->getMetaData());
defineRootName(c->scoped(), name ? *name : c->name());
- fprintbf(cpp, "template<>\nMetadata ModelPartForComplex< %s >::metadata ",
+ fprintbf(cpp, "template<>\nconst Metadata ModelPartForComplex< %s >::metadata ",
c->scoped());
copyMetadata(c->getMetaData());
@@ -262,7 +262,7 @@ namespace Slicer {
if (!cpp) return;
fprintbf(cpp, "template<>\n");
- fprintbf(cpp, "ModelPartForComplex< %s >::Hooks ",
+ fprintbf(cpp, "const ModelPartForComplex< %s >::Hooks ",
it->scoped());
fprintbf(cpp, "ModelPartForComplex< %s >::hooks {\n",
it->scoped());
@@ -318,7 +318,7 @@ namespace Slicer {
t = Slice::ClassDefPtr::dynamicCast(dm->container())->declaration();
}
auto type = dm->type();
- fprintbf(cpp, "template<>\ntemplate<>\nMetadata\n");
+ fprintbf(cpp, "template<>\ntemplate<>\nconst Metadata\n");
createNewModelPartPtrFor(t);
fprintbf(cpp, "< %s >::HookMetadata< %s",
typeToString(it),
@@ -340,11 +340,11 @@ namespace Slicer {
if (!cpp) return;
fprintbf(cpp, "// Enumeration %s\n", e->name());
- fprintbf(cpp, "template<>\nMetadata ModelPartForEnum< %s >::metadata ",
+ fprintbf(cpp, "template<>\nconst Metadata ModelPartForEnum< %s >::metadata ",
e->scoped());
copyMetadata(e->getMetaData());
- fprintbf(cpp, "template<>\nModelPartForEnum< %s >::Enumerations\nModelPartForEnum< %s >::enumerations([]() -> ModelPartForEnum< %s >::Enumerations\n",
+ fprintbf(cpp, "template<>\nconst ModelPartForEnum< %s >::Enumerations\nModelPartForEnum< %s >::enumerations([]() -> ModelPartForEnum< %s >::Enumerations\n",
e->scoped(),
e->scoped(),
e->scoped());
@@ -411,14 +411,14 @@ namespace Slicer {
fprintbf(cpp, "template<>\n");
auto ename = metaDataValue("slicer:element:", s->getMetaData());
- fprintbf(cpp, "std::string ModelPartForSequence< %s >::elementName(\"%s\");\n\n",
+ fprintbf(cpp, "const std::string ModelPartForSequence< %s >::elementName(\"%s\");\n\n",
s->scoped(),
ename ? *ename : "element");
auto name = metaDataValue("slicer:root:", s->getMetaData());
defineRootName(s->scoped(), name ? *name : s->name());
- fprintbf(cpp, "template<>\nMetadata ModelPartForSequence< %s >::metadata ",
+ fprintbf(cpp, "template<>\nconst Metadata ModelPartForSequence< %s >::metadata ",
s->scoped());
copyMetadata(s->getMetaData());
@@ -438,12 +438,12 @@ namespace Slicer {
fprintbf(cpp, "// Dictionary %s\n", d->name());
auto iname = metaDataValue("slicer:item:", d->getMetaData());
fprintbf(cpp, "template<>\n");
- fprintbf(cpp, "std::string ModelPartForDictionary< %s >::pairName(\"%s\");\n\n",
+ fprintbf(cpp, "const std::string ModelPartForDictionary< %s >::pairName(\"%s\");\n\n",
d->scoped(),
iname ? *iname : "element");
fprintbf(cpp, "template<>\n");
- fprintbf(cpp, "ModelPartForComplex< %s::value_type >::Hooks ",
+ fprintbf(cpp, "const ModelPartForComplex< %s::value_type >::Hooks ",
d->scoped());
fprintbf(cpp, "ModelPartForComplex< %s::value_type >::hooks {\n",
d->scoped());
@@ -476,11 +476,11 @@ namespace Slicer {
auto name = metaDataValue("slicer:root:", d->getMetaData());
defineRootName(d->scoped(), name ? *name : d->name());
- fprintbf(cpp, "template<>\nMetadata ModelPartForDictionary< %s >::metadata ",
+ fprintbf(cpp, "template<>\nconst Metadata ModelPartForDictionary< %s >::metadata ",
d->scoped());
copyMetadata(d->getMetaData());
- fprintbf(cpp, "template<>\nMetadata ModelPartForComplex<%s::value_type>::metadata ",
+ fprintbf(cpp, "template<>\nconst Metadata ModelPartForComplex<%s::value_type>::metadata ",
d->scoped());
copyMetadata(d->getMetaData());