Class GraphManager#

Nested Relationships#

Nested Types#

Class Documentation#

class GraphManager#

Owns the graphs in memory and the “heads”: root folders on the disk where graphs are saved. A graph with the qualifier “a.b.c” is saved in “<head>/a/b/c.graph”.

Public Types

enum class Owner#

Ordered from the most personal to the least personal: when saving, the most personal writable head is used.

Values:

enumerator User#
enumerator Group#
enumerator Global#
enumerator Unknown#
using head_id_t = std::size_t#
using library_t = std::map<qualifier_t, head_id_t>#
using heads_t = SmallMap<head_id_t, HeadProperties>#

Public Functions

GraphManager(const GraphManager&) = delete#
GraphManager &operator=(const GraphManager&) = delete#
~GraphManager() = default#
inline const library_t &get_library() const#
inline const heads_t &get_heads() const#
inline const Graph &get_graph(graph_id_t id) const#
Throws:

std::out_of_range – if the graph doesn’t exist.

inline Graph &get_graph(graph_id_t id)#
inline bool has_graph(graph_id_t id) const#
graph_id_t new_graph(const std::string &name = "")#
bool close_graph(graph_id_t id)#
Returns:

false if the graph doesn’t exist.

head_id_t add_head(const std::filesystem::path &path, Owner owner = Owner::User)#

Registers a new head and discovers the graphs it contains.

void refresh()#

Re-discovers the graphs contained in all the readable heads.

bool exists(const qualifier_t &q) const#
Returns:

true if a graph with this qualifier exists in one of the heads.

Status save_graph(graph_id_t id)#

Saves the graph in the most personal writable head.

Status save_graph(graph_id_t id, head_id_t head_id)#
Graph raw_read(const qualifier_t &q) const#

Reads a graph from the disk without registering it in the manager.

Throws:

std::runtime_error – if the graph can’t be found or read.

graph_id_t load_graph(const qualifier_t &q, bool force = false)#

Loads a graph from the disk and registers it in the manager. If it was already loaded and force is false, the ID of the graph in memory is returned.

Throws:

std::runtime_error – if the graph can’t be found or read.

void reset()#

Forgets everything: graphs in memory and heads. Mostly useful for tests.

Public Static Functions

static bool can_write(const std::filesystem::path &path)#
static bool can_read(const std::filesystem::path &path)#
static GraphManager &instance()#
struct HeadProperties#

Public Functions

inline HeadProperties(Owner owner = Owner::Unknown, const std::filesystem::path &path = "", bool readable = false, bool writable = false)#

Public Members

Owner owner#
std::filesystem::path path#
bool readable#
bool writable#