aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/crepe/Asset.cpp13
-rw-r--r--src/crepe/Asset.h18
-rw-r--r--src/crepe/api/BehaviorScript.h2
-rw-r--r--src/crepe/system/ScriptSystem.cpp2
-rw-r--r--src/crepe/system/ScriptSystem.h2
5 files changed, 23 insertions, 14 deletions
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 <class T>
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<Script *> ScriptSystem::get_scripts() {
+forward_list<Script *> ScriptSystem::get_scripts() const {
forward_list<Script *> scripts = {};
ComponentManager & mgr = ComponentManager::get_instance();
vector<reference_wrapper<BehaviorScript>> behavior_scripts
diff --git a/src/crepe/system/ScriptSystem.h b/src/crepe/system/ScriptSystem.h
index 4fa6141..f3d26d4 100644
--- a/src/crepe/system/ScriptSystem.h
+++ b/src/crepe/system/ScriptSystem.h
@@ -14,7 +14,7 @@ public:
private:
// TODO: to forward_list<reference_wrapper>
- std::forward_list<Script *> get_scripts();
+ std::forward_list<Script *> get_scripts() const;
};
} // namespace crepe