From f2294079a074c064415f7c1ffdb311d4a20b31be Mon Sep 17 00:00:00 2001 From: CHatingPython Date: Sat, 20 Jun 2026 12:42:42 +0200 Subject: [PATCH] docs(furvm): document the context Refs: #12 --- furvm/include/furvm/context.hpp | 84 ++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 6 deletions(-) diff --git a/furvm/include/furvm/context.hpp b/furvm/include/furvm/context.hpp index 55b5ddf..73bb4ce 100644 --- a/furvm/include/furvm/context.hpp +++ b/furvm/include/furvm/context.hpp @@ -17,7 +17,11 @@ class context { public: friend class executor; public: + /** + * @brief Constructs a context. + */ context(); + ~context() = default; /** @@ -33,44 +37,90 @@ public: context(const context&) = delete; context& operator=(const context&) = delete; public: + /** + * @brief Emplaces a module in the context. + * + * @param args Arguments forwarded to the module constructor. + * @return The emplaced module. + */ template auto emplace_module(Args&&... args) { return m_modules.emplace(std::forward(args)...); } + /** + * @brief Returns a module from the context. + * + * @param args Module's id. + * @return A handle to the module. + */ template auto module_at(Args&&... args) { return m_modules.at(std::forward(args)...); } + /** + * @brief Returns a module from the context. + * + * @param args Module's id. + * @return A handle to the module. + */ template auto module_at(Args&&... args) const { return m_modules.at(std::forward(args)...); } + /** + * @brief Erases a module from the context. + * + * @param args Module's id. + */ template - auto erase_module(Args&&... args) { - return m_modules.erase(std::forward(args)...); + void erase_module(Args&&... args) { + m_modules.erase(std::forward(args)...); } public: + /** + * @brief Emplaces an executor in the context. + * + * @param args Arguments forwarded to executor's constructor. + * @return A handle to the emplaced executor. + */ template auto emplace_executor(Args&&... args) { return m_executors.emplace_back(std::forward(args)...); } + /** + * @brief Returns an executor from the context. + * + * @param args Id of the executor. + * @return A handle to the executor. + */ template auto executor_at(Args&&... args) { return m_executors.at(std::forward(args)...); } + /** + * @brief Returns an executor from the context. + * + * @param args Id of the executor. + * @return A handle to the executor. + */ template auto executor_at(Args&&... args) const { return m_executors.at(std::forward(args)...); } + /** + * @brief Erases an executor from the context. + * + * @param args Id of the executor. + */ template - auto erase_executor(Args&&... args) { - return m_executors.erase(std::forward(args)...); + void erase_executor(Args&&... args) { + m_executors.erase(std::forward(args)...); } public: template @@ -78,21 +128,43 @@ public: return m_things.emplace_back(std::forward(args)...); } + /** + * @brief Returns a thing from the context. + * + * @param args Id of the thing. + * @return A handle to the thing. + */ template auto thing_at(Args&&... args) { return m_things.at(std::forward(args)...); } + /** + * @brief Returns a thing from the context. + * + * @param args Id of the thing. + * @return A handle to the thing. + */ template auto thing_at(Args&&... args) const { return m_things.at(std::forward(args)...); } + /** + * @brief Erases a thing from the context. + * + * @param args Id of the thing. + */ template - auto erase_thing(Args&&... args) { - return m_things.erase(std::forward(args)...); + void erase_thing(Args&&... args) { + m_things.erase(std::forward(args)...); } + /** + * @brief Returns context's thing allocator. + * + * @return The thing allocator. + */ thing_allocator thing_alloc() const { return m_thingAllocator; } private: handle_container m_modules;