#pragma once #include #include #include #include #include #include #include constexpr inline auto MAXIMUM_ERROR_INFOS = 8; /// \private struct IkarusProject { public: [[nodiscard]] auto get_name() const -> std::string_view; [[nodiscard]] auto get_path() const -> std::filesystem::path const&; [[nodiscard]] auto get_db() -> sqlitecpp::Connection *; [[nodiscard]] auto get_db() const -> sqlitecpp::Connection const *; public: [[nodiscard]] auto get_function_context() -> struct FunctionContext *; public: [[nodiscard]] auto get_blueprint(IkarusId id) -> struct IkarusBlueprint *; auto uncache_blueprint(struct IkarusBlueprint * blueprint) -> void; [[nodiscard]] auto get_entity(IkarusId id) -> struct IkarusEntity *; auto uncache_entity(struct IkarusEntity * entity) -> void; [[nodiscard]] auto get_property(IkarusId id) -> struct IkarusProperty *; auto uncache_property(struct IkarusProperty * property) -> void; private: template [[nodiscard]] T * get_cached_object(IkarusId id, std::unordered_map>& cache) { auto const iter = cache.find(id); if (iter == cache.cend()) { auto [ret_iter, _] = cache.emplace(id, std::make_unique(this, id)); return ret_iter->second.get(); } return iter->second.get(); } template void remove_cached_object(T * object, std::unordered_map>& cache) { cache.erase(object->id); } private: friend struct FunctionContext; std::string _name; std::filesystem::path _path; std::unique_ptr _db; std::array error_infos; std::string error_message_buffer; std::unordered_map> _blueprints; std::unordered_map> _properties; std::unordered_map> _entities; std::stack _function_contexts; };