#ifndef FURVM_CONTEXT_HPP #define FURVM_CONTEXT_HPP #include "furvm/executor.hpp" #include "furvm/fwd.hpp" #include "furvm/handle.hpp" #include "furvm/module.hpp" // IWYU pragma: keep #include "furvm/thing.hpp" // IWYU pragma: keep #include #include #include namespace furvm { class context : public handle_container { public: friend class executor; public: /** * @brief Constructs a context. */ context() {} ~context() = default; /** * @brief Move constructor. */ context(context&&) noexcept = default; /** * @brief Move constructor. */ context& operator=(context&&) noexcept = default; context(const context&) = delete; context& operator=(const context&) = delete; public: template auto& allocate_executor() { executor executor(this); return m_executors.emplace_back(std::move(executor)); } /** * @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 const auto& executor_at(Args&&... args) const { return m_executors.at(std::forward(args)...); } const std::vector& executors() const { return m_executors; } public: thing_type_store& tt_store() { return m_thingTypeStore; } public: template thing<> allocate_thing(Args&&... args) { thing<> thing = { std::forward(args)... }; m_heap.push_back(thing.raw()); return std::move(thing); } private: handle_container m_modules; std::vector m_executors; class thing_type_store m_thingTypeStore; // A list of things on the heap std::vector m_heap; }; } // namespace furvm #endif // FURVM_CONTEXT_HPP