summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slicer/slicer/modelParts.h21
-rw-r--r--slicer/slicer/slicer.h9
-rw-r--r--slicer/test/serializers.cpp6
3 files changed, 6 insertions, 30 deletions
diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h
index 73bdff2..8cf525a 100644
--- a/slicer/slicer/modelParts.h
+++ b/slicer/slicer/modelParts.h
@@ -204,27 +204,12 @@ namespace Slicer {
template<typename T>
class DLL_PUBLIC ModelPartForRoot : public ModelPart {
public:
- ModelPartForRoot() :
- ModelObject(new T()),
- owned(true),
- mp(ModelPartFor(*ModelObject))
- {
- }
-
ModelPartForRoot(T & o) :
ModelObject(&o),
- owned(false),
mp(ModelPartFor(*ModelObject))
{
}
- ~ModelPartForRoot()
- {
- if (owned) {
- delete ModelObject;
- }
- }
-
virtual ChildRefPtr GetAnonChildRef(const HookFilter &) override
{
mp->Create();
@@ -245,11 +230,6 @@ namespace Slicer {
ch(rootName, mp, NULL);
}
- T & GetModel()
- {
- return *ModelObject;
- }
-
virtual bool HasValue() const override { return ModelObject && mp->HasValue(); }
virtual ModelPartType GetType() const override
@@ -261,7 +241,6 @@ namespace Slicer {
private:
T * ModelObject;
- bool owned;
ModelPartPtr mp;
DLL_PUBLIC static std::string rootName;
};
diff --git a/slicer/slicer/slicer.h b/slicer/slicer/slicer.h
index 6efaa38..8a439d9 100644
--- a/slicer/slicer/slicer.h
+++ b/slicer/slicer/slicer.h
@@ -17,9 +17,9 @@ namespace Slicer {
Object
DeserializeAnyWith(DeserializerPtr deserializer)
{
- IceUtil::Handle<ModelPartForRoot<Object>> root = new ModelPartForRoot<Object>();
- deserializer->Deserialize(root);
- return root->GetModel();
+ Object object;
+ deserializer->Deserialize(new ModelPartForRoot<Object>(object));
+ return object;
}
template <typename Deserializer, typename Object, typename ... SerializerParams>
@@ -40,8 +40,7 @@ namespace Slicer {
void
SerializeAnyWith(Object object, SerializerPtr serializer)
{
- IceUtil::Handle<ModelPartForRoot<Object>> root = new ModelPartForRoot<Object>(object);
- serializer->Serialize(root);
+ serializer->Serialize(new ModelPartForRoot<Object>(object));
}
template <typename Serializer, typename Object, typename ... SerializerParams>
diff --git a/slicer/test/serializers.cpp b/slicer/test/serializers.cpp
index 4870bec..f2adced 100644
--- a/slicer/test/serializers.cpp
+++ b/slicer/test/serializers.cpp
@@ -456,13 +456,11 @@ BOOST_AUTO_TEST_CASE( xml_streams )
BOOST_AUTO_TEST_CASE( invalid_enum )
{
- IceUtil::Handle<Slicer::ModelPartForRoot<TestModule::SomeNumbers>> rootmp = new Slicer::ModelPartForRoot<TestModule::SomeNumbers>();
-
Slicer::DeserializerPtr jdeserializer = new Slicer::JsonFileDeserializer(root / "initial" / "invalidEnum.json");
- BOOST_REQUIRE_THROW(jdeserializer->Deserialize(rootmp), Slicer::InvalidEnumerationValue);
+ BOOST_REQUIRE_THROW(Slicer::DeserializeAnyWith<TestModule::SomeNumbers>(jdeserializer), Slicer::InvalidEnumerationValue);
Slicer::DeserializerPtr xdeserializer = new Slicer::XmlFileDeserializer(root / "initial" / "invalidEnum.xml");
- BOOST_REQUIRE_THROW(xdeserializer->Deserialize(rootmp), Slicer::InvalidEnumerationValue);
+ BOOST_REQUIRE_THROW(Slicer::DeserializeAnyWith<TestModule::SomeNumbers>(xdeserializer), Slicer::InvalidEnumerationValue);
}
BOOST_AUTO_TEST_SUITE_END();