Merge branch 'master' of git.c3d2.de:sic++
This commit is contained in:
commit
9a8fb2f600
|
@ -23,6 +23,8 @@ public:
|
||||||
return me;
|
return me;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int event_route(struct mg_event *event)
|
static int event_route(struct mg_event *event)
|
||||||
{
|
{
|
||||||
// Foohash fh;
|
// Foohash fh;
|
||||||
|
@ -43,12 +45,16 @@ public:
|
||||||
}
|
}
|
||||||
std::string const & get_baseurl()const{return _baseurl;}
|
std::string const & get_baseurl()const{return _baseurl;}
|
||||||
void set_baseurl(std::string baseurl);
|
void set_baseurl(std::string baseurl);
|
||||||
|
|
||||||
|
std::string const & get_persist_path() const { return perists_path;}
|
||||||
private:
|
private:
|
||||||
explicit Routerin();
|
explicit Routerin();
|
||||||
std::unique_ptr<StaticFileHandler> sfh;
|
std::unique_ptr<StaticFileHandler> sfh;
|
||||||
DynamicObjects * _dyn_obs;
|
DynamicObjects * _dyn_obs;
|
||||||
std::string _baseurl;
|
std::string _baseurl;
|
||||||
|
|
||||||
|
std::string perists_path;
|
||||||
|
|
||||||
bool hasInstance = false;
|
bool hasInstance = false;
|
||||||
|
|
||||||
int event_request_route ( struct mg_event *event);
|
int event_request_route ( struct mg_event *event);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "Routerin.H"
|
||||||
|
|
||||||
#include "sicccobject.H"
|
#include "sicccobject.H"
|
||||||
|
|
||||||
|
@ -101,37 +102,28 @@ static std::string get_json_string_representation(const json_t *j)
|
||||||
class SicccPersister
|
class SicccPersister
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SicccPersister()
|
SicccPersister(const Routerin & merouter = *Routerin::get_instance()) :
|
||||||
|
merouter(merouter)
|
||||||
{
|
{
|
||||||
root = json_object();
|
root = json_object();
|
||||||
perists_path = "./";
|
perists_path = "./";
|
||||||
json_file_name = "foo.json"; // not the best default
|
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);
|
root = get_json_from_sicccobject(so);
|
||||||
perists_path = "./";
|
perists_path =
|
||||||
json_file_name = so.get_filename();
|
json_file_name = so.get_filename();
|
||||||
}
|
}
|
||||||
|
|
||||||
SicccPersister(json_t *j)
|
SicccPersister(json_t *j, const Routerin & merouter =* Routerin::get_instance())
|
||||||
{
|
{
|
||||||
root = json_object();
|
root = json_object();
|
||||||
json_object_update(root, j);
|
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()
|
~SicccPersister()
|
||||||
{
|
{
|
||||||
if (root)
|
if (root)
|
||||||
|
@ -160,8 +152,9 @@ class SicccPersister
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string perists_path;
|
const Routerin & merouter;
|
||||||
std::string json_file_name;
|
/* std::string perists_path;
|
||||||
|
std::string json_file_name; */
|
||||||
json_t *root;
|
json_t *root;
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
|
Loading…
Reference in New Issue