|
|
|
@ -7,6 +7,7 @@
|
|
|
|
|
#include <cstring>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#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
|
|
|
|
|