From ed0020756aa30752c5928b21c5820020a14ad8c8 Mon Sep 17 00:00:00 2001 From: john stone Date: Thu, 1 May 2014 23:39:14 +0200 Subject: [PATCH] prepare merging double development --- src/Routerin.H | 6 ++++++ src/sicccPersister.H | 27 ++++++++++----------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Routerin.H b/src/Routerin.H index d109233..69660d0 100644 --- a/src/Routerin.H +++ b/src/Routerin.H @@ -23,6 +23,8 @@ public: return me; } + + static int event_route(struct mg_event *event) { // Foohash fh; @@ -43,12 +45,16 @@ public: } std::string const & get_baseurl()const{return _baseurl;} void set_baseurl(std::string baseurl); + + std::string const & get_persist_path() const { return perists_path;} private: explicit Routerin(); std::unique_ptr sfh; DynamicObjects * _dyn_obs; std::string _baseurl; + std::string perists_path; + bool hasInstance = false; int event_request_route ( struct mg_event *event); diff --git a/src/sicccPersister.H b/src/sicccPersister.H index 647f962..97ff339 100644 --- a/src/sicccPersister.H +++ b/src/sicccPersister.H @@ -7,6 +7,7 @@ #include #include #include +#include "Routerin.H" #include "sicccobject.H" @@ -101,37 +102,28 @@ static std::string get_json_string_representation(const json_t *j) class SicccPersister { public: - SicccPersister() + SicccPersister(const Routerin & merouter = *Routerin::get_instance()) : + merouter(merouter) { root = json_object(); perists_path = "./"; json_file_name = "foo.json"; // not the best default }; - SicccPersister(const Sicccobject& so) + SicccPersister(const Sicccobject& so,const Routerin &merouter = * Routerin::get_instance()): + merouter(merouter) { root = get_json_from_sicccobject(so); - perists_path = "./"; + perists_path = json_file_name = so.get_filename(); } - SicccPersister(json_t *j) + SicccPersister(json_t *j, const Routerin & merouter =* Routerin::get_instance()) { root = json_object(); json_object_update(root, j); } - /*TODO - * clean up path handling - */ - SicccPersister(const std::string& jsonfilename, - const std::string& storepath - ) : perists_path(storepath), json_file_name(jsonfilename) - { - root = load_json(std::string(perists_path + json_file_name)); - assert(root); - } - ~SicccPersister() { if (root) @@ -160,8 +152,9 @@ class SicccPersister } private: - std::string perists_path; - std::string json_file_name; + const Routerin & merouter; + /* std::string perists_path; + std::string json_file_name; */ json_t *root; std::string