summaryrefslogtreecommitdiff
path: root/slicer
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2014-09-03 19:11:03 +0000
committerrandomdan <randomdan@localhost>2014-09-03 19:11:03 +0000
commitde27a7b63887f4bdb335b496dc1f3757a73aae47 (patch)
treef846fb2d6e3d00c59e18d1107d546498bbe43c02 /slicer
parentIgnore interfaces (diff)
downloadslicer-de27a7b63887f4bdb335b496dc1f3757a73aae47.tar.bz2
slicer-de27a7b63887f4bdb335b496dc1f3757a73aae47.tar.xz
slicer-de27a7b63887f4bdb335b496dc1f3757a73aae47.zip
Fix serializer interface to operate only on model part, everything else is via implementor's constructor
Diffstat (limited to 'slicer')
-rw-r--r--slicer/json/serializer.cpp9
-rw-r--r--slicer/json/serializer.h9
-rw-r--r--slicer/slicer/serializer.h4
-rw-r--r--slicer/slicer/slicer.h8
-rw-r--r--slicer/xml/serializer.cpp9
-rw-r--r--slicer/xml/serializer.h9
6 files changed, 34 insertions, 14 deletions
diff --git a/slicer/json/serializer.cpp b/slicer/json/serializer.cpp
index e9cd58c..dcce094 100644
--- a/slicer/json/serializer.cpp
+++ b/slicer/json/serializer.cpp
@@ -156,6 +156,11 @@ namespace Slicer {
ModelPartPtr modelPart;
};
+ Json::Json(const boost::filesystem::path & p) :
+ path(p)
+ {
+ }
+
void
Json::ModelTreeIterateSeq(json::Value * n, ModelPartPtr mp)
{
@@ -228,7 +233,7 @@ namespace Slicer {
}
void
- Json::Deserialize(const boost::filesystem::path & path, ModelPartPtr modelRoot)
+ Json::Deserialize(ModelPartPtr modelRoot)
{
std::ifstream inFile(path.string());
std::stringstream buffer;
@@ -240,7 +245,7 @@ namespace Slicer {
}
void
- Json::Serialize(const boost::filesystem::path & path, ModelPartPtr modelRoot)
+ Json::Serialize(ModelPartPtr modelRoot)
{
json::Value doc;
modelRoot->OnEachChild(boost::bind(&Json::ModelTreeIterateRoot, &doc, _2));
diff --git a/slicer/json/serializer.h b/slicer/json/serializer.h
index 0d70f21..c6bfb52 100644
--- a/slicer/json/serializer.h
+++ b/slicer/json/serializer.h
@@ -10,13 +10,18 @@ namespace json {
namespace Slicer {
class Json : public Serializer {
public:
- virtual void Deserialize(const boost::filesystem::path &, ModelPartPtr) override;
- virtual void Serialize(const boost::filesystem::path &, ModelPartPtr) override;
+ Json(const boost::filesystem::path &);
+
+ virtual void Deserialize(ModelPartPtr) override;
+ virtual void Serialize(ModelPartPtr) override;
protected:
static void ModelTreeIterate(json::Value *, const std::string &, ModelPartPtr mp);
static void ModelTreeIterateSeq(json::Value *, ModelPartPtr mp);
static void ModelTreeIterateRoot(json::Value *, ModelPartPtr mp);
+
+ private:
+ const boost::filesystem::path path;
};
}
diff --git a/slicer/slicer/serializer.h b/slicer/slicer/serializer.h
index dffa0f6..d89f9aa 100644
--- a/slicer/slicer/serializer.h
+++ b/slicer/slicer/serializer.h
@@ -9,8 +9,8 @@
namespace Slicer {
class Serializer : public IceUtil::Shared {
public:
- virtual void Deserialize(const boost::filesystem::path &, ModelPartPtr) = 0;
- virtual void Serialize(const boost::filesystem::path &, ModelPartPtr) = 0;
+ virtual void Deserialize(ModelPartPtr) = 0;
+ virtual void Serialize(ModelPartPtr) = 0;
};
typedef IceUtil::Handle<Serializer> SerializerPtr;
}
diff --git a/slicer/slicer/slicer.h b/slicer/slicer/slicer.h
index 0900bf9..01b040d 100644
--- a/slicer/slicer/slicer.h
+++ b/slicer/slicer/slicer.h
@@ -12,8 +12,8 @@ namespace Slicer {
Deserialize(const boost::filesystem::path & path)
{
IceUtil::Handle<ModelPartForClassRoot<IceInternal::Handle<Object>>> root = new ModelPartForClassRoot<IceInternal::Handle<Object>>();
- SerializerPtr serializer = new Serializer();
- serializer->Deserialize(path, root);
+ SerializerPtr serializer = new Serializer(path);
+ serializer->Deserialize(root);
return root->GetModel();
}
@@ -22,8 +22,8 @@ namespace Slicer {
Serialize(IceInternal::Handle<Object> object, const boost::filesystem::path & path)
{
IceUtil::Handle<ModelPartForClassRoot<IceInternal::Handle<Object>>> root = new ModelPartForClassRoot<IceInternal::Handle<Object>>(object);
- SerializerPtr serializer = new Serializer();
- serializer->Serialize(path, root);
+ SerializerPtr serializer = new Serializer(path);
+ serializer->Serialize(root);
}
}
diff --git a/slicer/xml/serializer.cpp b/slicer/xml/serializer.cpp
index bc593da..15d954e 100644
--- a/slicer/xml/serializer.cpp
+++ b/slicer/xml/serializer.cpp
@@ -160,6 +160,11 @@ namespace Slicer {
}
};
+ Xml::Xml(const boost::filesystem::path & p) :
+ path(p)
+ {
+ }
+
void
Xml::DocumentTreeIterate(const xmlpp::Node * node, ModelPartPtr mp)
{
@@ -230,7 +235,7 @@ namespace Slicer {
}
void
- Xml::Deserialize(const boost::filesystem::path & path, ModelPartPtr modelRoot)
+ Xml::Deserialize(ModelPartPtr modelRoot)
{
xmlpp::DomParser dom(path.string());
auto doc = dom.get_document();
@@ -238,7 +243,7 @@ namespace Slicer {
}
void
- Xml::Serialize(const boost::filesystem::path & path, ModelPartPtr modelRoot)
+ Xml::Serialize(ModelPartPtr modelRoot)
{
xmlpp::Document doc;
modelRoot->OnEachChild(boost::bind(&Xml::ModelTreeIterateRoot, &doc, _1, _2));
diff --git a/slicer/xml/serializer.h b/slicer/xml/serializer.h
index 8e8a023..487070b 100644
--- a/slicer/xml/serializer.h
+++ b/slicer/xml/serializer.h
@@ -14,14 +14,19 @@ namespace xmlpp {
namespace Slicer {
class Xml : public Serializer {
public:
- virtual void Deserialize(const boost::filesystem::path &, ModelPartPtr) override;
- virtual void Serialize(const boost::filesystem::path &, ModelPartPtr) override;
+ Xml(const boost::filesystem::path &);
+
+ virtual void Deserialize(ModelPartPtr) override;
+ virtual void Serialize(ModelPartPtr) override;
protected:
static void DocumentTreeIterate(const xmlpp::Node * node, ModelPartPtr mp);
static void DocumentTreeIterate(const xmlpp::Document * doc, ModelPartPtr mp);
static void ModelTreeIterate(xmlpp::Element *, const std::string &, ModelPartPtr mp);
static void ModelTreeIterateRoot(xmlpp::Document *, const std::string &, ModelPartPtr mp);
+
+ private:
+ const boost::filesystem::path path;
};
}