From 202725f481e64c4d95e370102ab93d4f8cf4af93 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 13 Nov 2024 14:51:02 +0100 Subject: incorporate feedback on #26 --- src/crepe/Asset.cpp | 13 +++++++------ src/crepe/Asset.h | 18 +++++++++++++----- src/crepe/api/BehaviorScript.h | 2 +- src/crepe/system/ScriptSystem.cpp | 2 +- src/crepe/system/ScriptSystem.h | 2 +- 5 files changed, 23 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/crepe/Asset.cpp b/src/crepe/Asset.cpp index 8a2a11c..4affd58 100644 --- a/src/crepe/Asset.cpp +++ b/src/crepe/Asset.cpp @@ -3,14 +3,15 @@ #include "Asset.h" using namespace crepe; +using namespace std; -Asset::Asset(const std::string & src) { - // FIXME: restore this - // this->src = std::filesystem::canonical(src); - this->src = src; +// FIXME: restore this +// src(std::filesystem::canonical(src)) +Asset::Asset(const std::string & src) : src(src) { this->file = std::ifstream(this->src, std::ios::in | std::ios::binary); } -const std::istream & Asset::read() { return this->file; } +istream & Asset::get_stream() { return this->file; } + +const string & Asset::get_canonical() const { return this->src; } -const char * Asset::canonical() { return this->src.c_str(); } diff --git a/src/crepe/Asset.h b/src/crepe/Asset.h index 0cb5834..cb413f4 100644 --- a/src/crepe/Asset.h +++ b/src/crepe/Asset.h @@ -20,13 +20,21 @@ public: Asset(const std::string & src); public: - //! Get an input stream to the contents of this resource - const std::istream & read(); - //! Get the canonical path to this resource - const char * canonical(); + /** + * \brief Get an input stream to the contents of this asset + * \return Input stream with file contents + */ + std::istream & get_stream(); + /** + * \brief Get the canonical path to this asset + * \return Canonical path to this asset + */ + const std::string & get_canonical() const; private: - std::string src; + //! Canonical path to asset + const std::string src; + //! File handle (stream) std::ifstream file; }; diff --git a/src/crepe/api/BehaviorScript.h b/src/crepe/api/BehaviorScript.h index 6b1fec7..c20842d 100644 --- a/src/crepe/api/BehaviorScript.h +++ b/src/crepe/api/BehaviorScript.h @@ -16,7 +16,7 @@ protected: using Component::Component; public: - virtual ~BehaviorScript() = default; + ~BehaviorScript() = default; public: template diff --git a/src/crepe/system/ScriptSystem.cpp b/src/crepe/system/ScriptSystem.cpp index aceb218..807ad7f 100644 --- a/src/crepe/system/ScriptSystem.cpp +++ b/src/crepe/system/ScriptSystem.cpp @@ -20,7 +20,7 @@ void ScriptSystem::update() { for (Script * script : scripts) script->update(); } -forward_list