From 734e07fdbb2ecffe5961912a160ba36072d9350d Mon Sep 17 00:00:00 2001 From: Joseph Walton-Rivers <joseph@walton-rivers.uk> Date: Fri, 2 Sep 2022 02:43:36 +0100 Subject: [PATCH] start to document the library --- include/fggl/fggl.hpp | 1 + include/fggl/modules/manager.hpp | 37 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/fggl/fggl.hpp b/include/fggl/fggl.hpp index db5e9d3..67eda43 100644 --- a/include/fggl/fggl.hpp +++ b/include/fggl/fggl.hpp @@ -29,6 +29,7 @@ #include "fggl/audio/null_audio.hpp" #include "fggl/audio/openal/module.hpp" +//! Root namespace namespace fggl { } diff --git a/include/fggl/modules/manager.hpp b/include/fggl/modules/manager.hpp index 23db222..791d2f0 100644 --- a/include/fggl/modules/manager.hpp +++ b/include/fggl/modules/manager.hpp @@ -31,15 +31,36 @@ namespace fggl::modules { + /** + * A class used for representing a Directed Acyclic Graph. + * + * This class is mostly used for establishing the loading order of classes for module loading. + * + * @tparam T the type being represented + */ template<typename T> class DependencyGraph { public: DependencyGraph() = default; + /** + * Clear all currently stored dependencies. + * + * This method will result in the dependency graph being empty, with no known modules. + */ void clear() { m_dependencies.clear(); } + /** + * Add a series of dependencies for an entry. + * + * If the entry does not already exist, this will create the entry before adding the dependencies to it. + * If the entry already exists, this will append the provided dependencies to its existing list. + * + * @param name the entry having dependencies added + * @param dependencies the things it depends on + */ void addAll(const T &name, const std::vector<T> &dependencies) { auto existing = m_dependencies.find(name); if (existing == m_dependencies.end()) { @@ -49,6 +70,15 @@ namespace fggl::modules { } } + /** + * Add a single dependency to the graph. + * + * If the entry does not already exist, this will create the entry before adding the dependencies to it. + * If the entry already exists, this will append the provided dependencies to its existing list. + * + * @param name the entry which depends something else + * @param depends the thing it depends on + */ void add(const T &name, const T &depends) { m_dependencies[name].push_back(depends); } @@ -103,6 +133,13 @@ namespace fggl::modules { } }; + /** + * Store and initialise modules present in the engine. + * + * This class is responsible for keeping track of which modules the library user has requested, and ensuring that + * their dependencies are loaded in the correct order. Once the dependency graph has been built and instances + * created, it is responsible for providing references to these initialised classes. + */ class Manager { public: Manager() = default; -- GitLab