Webdar 1.0.0
Web user interface to libdar
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
bibliotheque Class Reference

class bibliotheque More...

#include <bibliotheque.hpp>

Inheritance diagram for bibliotheque:
Inheritance graph
[legend]
Collaboration diagram for bibliotheque:
Collaboration graph
[legend]

Classes

struct  coordinates
 complete configuration designation More...
 

Public Types

enum  category {
  filefilter = 0 , pathfilter = 1 , command = 2 , repo = 3 ,
  compress = 4 , confsave = 5 , conftest = 6 , confdiff = 7 ,
  conflist = 8 , confrest = 9 , confmerge = 10 , confrepair = 11 ,
  confcommon = 12 , slicing = 13 , ciphering = 14 , delta_sig = 15 ,
  over_policy = 16 , confread = 17 , confisolate = 18 , EOE = 19
}
 change event is replaced by a static method with category in argument More...
 
typedef std::set< coordinatesusing_set
 list of configs a given config depends on
 

Public Member Functions

 bibliotheque (const bibliotheque &ref)=default
 
 bibliotheque (bibliotheque &&ref) noexcept(false)=default
 
bibliothequeoperator= (const bibliotheque &ref)=default
 
bibliothequeoperator= (bibliotheque &&ref) noexcept(false)=default
 
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 More...
 
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) More...
 
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) More...
 
void delete_config (category categ, const std::string &name)
 remove a configuration More...
 
void delete_external_ref_to (category categ, const std::string &name, const void *from_where)
 remove external ref to a configuration More...
 
bool has_config (category categ, const std::string &name) const
 tells whether a given cat/config exists
 
json fetch_config (category categ, const std::string &name) const
 provide a stored configuration More...
 
std::string display_config (category categ, const std::string &name) const
 display beautifulized json data for the given category and name
 
std::deque< std::string > listing (category categ) const
 list existing configurations under the provided category
 
bool get_saved_status () const
 get saved status More...
 
bool get_autosave_status () const
 get the autosave property More...
 
void set_autosave_status (bool val)
 set the autosave property More...
 
void clear ()
 clear all stored configurations
 
bool is_empty () const
 whether the bibliotheque has some configuration in one or more categories
 
virtual void load_json (const json &source) override
 inherited from jsoner More...
 
virtual json save_json () const override
 inherited from jsoner More...
 
virtual void clear_json () override
 inherited from jsoner More...
 
- Public Member Functions inherited from jsoner
 jsoner (const jsoner &ref)=default
 
 jsoner (jsoner &&ref) noexcept(false)=default
 
jsoneroperator= (const jsoner &ref)=default
 
jsoneroperator= (jsoner &&ref) noexcept(false)=default
 
virtual void load_json (const json &source)=0
 setup the components from the json provided information More...
 
virtual json save_json () const =0
 produce a json structure from the component configuration More...
 
virtual void clear_json ()=0
 instruct the object to get to its default/initial configuration More...
 
- Public Member Functions inherited from events
 events (const events &ref)
 copy constructor More...
 
 events (events &&ref) noexcept(false)=default
 
eventsoperator= (const events &ref)=default
 
eventsoperator= (events &&ref) noexcept(false)
 
void record_actor_on_event (actor *ptr, const std::string &name)
 record an actor for an given event
 
- Public Member Functions inherited from reference
 reference ()
 usual constructor
 
 reference (const reference &ref)
 copy constructor More...
 
 reference (reference &&ref) noexcept(false)
 move constructor (only operational for objects without peering) More...
 
referenceoperator= (const reference &ref)
 assignment operator (only operational for objects without peering) More...
 
referenceoperator= (reference &&ref) noexcept(false)
 move assigment operator More...
 
virtual ~reference ()
 destructor
 
void peer_with (reference *obj)
 method used to create a relation between two objects More...
 
void break_peer_with (reference *obj)
 break the peering with the object given as argument
 
bool is_peer (reference *obj) const
 whether a peering exists with that object
 
bool is_empty () const
 whether the current object has peering
 
unsigned int size () const
 the number of peers
 

Static Public Member Functions

static std::string changed (category cat)
 change event per category
 
static std::string category_to_string (category cat)
 convert category to json used string
 
static category string_to_category (const std::string &s)
 convert json used string to category
 
static std::string category_description (category cat, bool capitalized)
 provide user displayable category description
 

Static Public Attributes

static constexpr const char * default_config_name = "default"
 name of default configuration for options
 
static constexpr const char * default_no_compression = "no-compress"
 
static constexpr const char * default_full_from_diff = "full from diff"
 

Additional Inherited Members

- Protected Member Functions inherited from events
virtual void broken_peering_from (reference *obj) override
 inherited from class reference More...
 
void register_name (const std::string &name)
 add a new event for actors to register against
 
void unregister_name (const std::string &name)
 remove an event and remove all actors that registed on it
 
void rename_name (const std::string &old_name, const std::string &new_name)
 rename an event and keep all existing peering to this new event More...
 
void act (const std::string &name)
 trigger a given event
 
- Protected Member Functions inherited from reference
virtual void broken_peering_from (reference *obj)
 to be informed when a peer has broke the peering with me More...
 
void reset_read_peers () const
 reset the peers reading
 
bool read_next_peer (reference *&peer) const
 
- Static Protected Member Functions inherited from jsoner
static json wrap_config_with_json_header (unsigned int version, const std::string &class_id, const json &config)
 given a version, class_id and configuration generates the global and common json structure More...
 
static json unwrap_config_from_json_header (const json &source, unsigned int &version, std::string &class_id)
 from a given json global and common json structure split header parts and return the config part More...
 
- Static Protected Attributes inherited from jsoner
static constexpr const char * jsoner_version_label = "version"
 
static constexpr const char * jsoner_id_label = "class_id"
 
static constexpr const char * jsoner_config_label = "config"
 

Detailed Description

class bibliotheque

class bibliotheque purpose is associate json configurations to a name and a category, and provide means to store, search, update and delete them as a whole. This class provides its own configuration (including configuration of it stores) as a jsoner class.

Member Enumeration Documentation

◆ category

change event is replaced by a static method with category in argument

json objects are split into category, each used as a different "namespace"

Enumerator
EOE 

not a valid value, used for interating in the enum

Member Function Documentation

◆ add_config()

void bibliotheque::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

Note
throw exception_range if name already exist

◆ add_external_ref_to()

void bibliotheque::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)

Note
this only put a flag on a given config for it does not be deleted until the external refs are all cleared

◆ clear_json()

virtual void bibliotheque::clear_json ( )
inlineoverridevirtual

inherited from jsoner

Implements jsoner.

◆ delete_config()

void bibliotheque::delete_config ( category  categ,
const std::string &  name 
)

remove a configuration

Note
throw exception_range if name does not exist

◆ delete_external_ref_to()

void bibliotheque::delete_external_ref_to ( category  categ,
const std::string &  name,
const void *  from_where 
)

remove external ref to a configuration

Note
from_where must be the same string as the one passed to add_external_ref_to

◆ fetch_config()

json bibliotheque::fetch_config ( category  categ,
const std::string &  name 
) const

provide a stored configuration

Note
throw exception_range if name does not exist

◆ get_autosave_status()

bool bibliotheque::get_autosave_status ( ) const
inline

get the autosave property

Note
this property does not drive any action here but is left available to decide whether or not to save the bibliotheque upon change by component using it (html_bibliotheque)

◆ get_saved_status()

bool bibliotheque::get_saved_status ( ) const
inline

get saved status

Note
saved status is set when adding or modifying config, but is cleared when loading or saving as json.

◆ load_json()

void bibliotheque::load_json ( const json &  source)
overridevirtual

inherited from jsoner

Implements jsoner.

◆ save_json()

json bibliotheque::save_json ( ) const
overridevirtual

inherited from jsoner

Implements jsoner.

◆ set_autosave_status()

void bibliotheque::set_autosave_status ( bool  val)
inline

set the autosave property

Note
same note as the one for get_autosave_status()

◆ update_config()

void bibliotheque::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)

Note
throw exception_range if name does not exist

The documentation for this class was generated from the following files: