24#ifndef BIBLIOTHEQUE_HPP
25#define BIBLIOTHEQUE_HPP
88 static constexpr const char* default_no_compression =
"no-compress";
89 static constexpr const char* default_full_from_diff =
"full from diff";
110 std::string confname;
113 bool operator < (
const coordinates & ref)
const {
return cat < ref.cat || (cat == ref.cat && confname < ref.confname); };
192 virtual void load_json(
const json & source)
override;
213 linked_config(
const json & conf) { config = conf; };
214 linked_config(
const json & conf,
const std::set<coordinates> & deps): config(conf), dependency(deps) {};
218 typedef std::map<std::string, linked_config> asso;
221 typedef std::map<category, asso> table;
237 typedef std::set<const void*> refs;
239 std::map<coordinates, refs> outside;
253 const std::string & name,
255 table::iterator & catit)
const;
257 void add_dependency_for(coordinates user,
const using_set & referred);
258 void remove_dependency_for(coordinates user);
259 using_set get_direct_dependencies_of(coordinates user)
const;
260 void check_against_cyclic_dependencies(coordinates source,
const std::set<coordinates> & seen);
263 static constexpr const unsigned int format_version = 1;
264 static constexpr const char* myclass_id =
"bibliotheque";
266 static constexpr const char* category_label =
"category";
267 static constexpr const char* asso_label =
"list";
268 static constexpr const char* config_label =
"name";
269 static constexpr const char* config_def_label =
"config";
270 static constexpr const char* config_depend =
"used-by";
272 static constexpr const char* jlabel_categprop =
"categories";
273 static constexpr const char* jlabel_globalprop =
"global";
275 static constexpr const char* jlabel_autosave =
"auto-save";
class bibliotheque
Definition: bibliotheque.hpp:56
std::set< coordinates > using_set
list of configs a given config depends on
Definition: bibliotheque.hpp:117
virtual json save_json() const override
inherited from jsoner
Definition: bibliotheque.cpp:477
virtual void load_json(const json &source) override
inherited from jsoner
Definition: bibliotheque.cpp:374
void update_config(category categ, const std::string &name, const json &config, const using_set &refs=std::set< coordinates >())
update an existing configuration for that category (name must exist)
Definition: bibliotheque.cpp:212
void delete_config(category categ, const std::string &name)
remove a configuration
Definition: bibliotheque.cpp:243
virtual void clear_json() override
inherited from jsoner
Definition: bibliotheque.hpp:198
static std::string changed(category cat)
change event per category
Definition: bibliotheque.cpp:45
static constexpr const char * default_config_name
name of default configuration for options
Definition: bibliotheque.hpp:87
static std::string category_to_string(category cat)
convert category to json used string
Definition: bibliotheque.cpp:619
bool has_config(category categ, const std::string &name) const
tells whether a given cat/config exists
Definition: bibliotheque.cpp:307
void clear()
clear all stored configurations
Definition: bibliotheque.cpp:345
void add_external_ref_to(category categ, const std::string &name, const void *from_where)
add external reference to a config (avoiding it to be deleted)
Definition: bibliotheque.cpp:175
json fetch_config(category categ, const std::string &name) const
provide a stored configuration
Definition: bibliotheque.cpp:315
static std::string category_description(category cat, bool capitalized)
provide user displayable category description
Definition: bibliotheque.cpp:712
std::deque< std::string > listing(category categ) const
list existing configurations under the provided category
Definition: bibliotheque.cpp:331
category
change event is replaced by a static method with category in argument
Definition: bibliotheque.hpp:63
@ EOE
not a valid value, used for interating in the enum
Definition: bibliotheque.hpp:83
bool get_autosave_status() const
get the autosave property
Definition: bibliotheque.hpp:178
void delete_external_ref_to(category categ, const std::string &name, const void *from_where)
remove external ref to a configuration
Definition: bibliotheque.cpp:287
void add_config(category categ, const std::string &name, const json &config, const using_set &refs=std::set< coordinates >())
add a new configuration, the name must not exist for that category
Definition: bibliotheque.cpp:141
bool is_empty() const
whether the bibliotheque has some configuration in one or more categories
Definition: bibliotheque.cpp:354
bool get_saved_status() const
get saved status
Definition: bibliotheque.hpp:171
static category string_to_category(const std::string &s)
convert json used string to category
Definition: bibliotheque.cpp:668
void set_autosave_status(bool val)
set the autosave property
Definition: bibliotheque.hpp:183
std::string display_config(category categ, const std::string &name) const
display beautifulized json data for the given category and name
Definition: bibliotheque.cpp:326
class events
Definition: events.hpp:52
class jsoner
Definition: jsoner.hpp:73
defines jsoner class and class exception_json
complete configuration designation
Definition: bibliotheque.hpp:108