16 inline std::string getResourceLocation()
const {
return this->m_location.c_str(); }
18 inline std::string getResourceName()
const {
return this->m_name.c_str(); }
20 inline std::string getResourceContent()
const {
return this->m_content.c_str(); }
22 inline unsigned int getResourceId()
const {
return this->m_id; }
24 inline void setResourceId(
const unsigned int &
id) { this->m_id = id; }
26 inline bool isResourceLoaded()
const {
return !this->m_content.empty(); }
30 void unloadResource();
34 Resource(
const std::string &location,
const std::string &file) : m_location(std::move(location)), m_file(std::move(file)) {
35 this->m_name = std::string(this->m_file);
38 Resource(
const std::string &file) : Resource(res::DEFAULT_LOCATION, file) {}
40 ~Resource() =
default;
43 unsigned int m_id = 0;
44 std::string m_location;
47 std::string m_content;
54class ResourceManager {
56 unsigned int addResource(
const std::string &location,
const std::string &file);
58 unsigned int addResource(
const std::string &file);
60 bool removeResource(
const unsigned int&
id);
62 inline unsigned int getCurrentId()
const {
return this->m_currentId; }
64 Resource getResource(
const unsigned int &
id)
const;
66 ResourceManager(ResourceManager &other) =
delete;
68 void operator=(
const ResourceManager &other) =
delete;
70 inline static Shared<ResourceManager> instance() {
71 if (s_pointer ==
nullptr) {
72 Shared<ResourceManager> copy(
new ResourceManager());
79 inline static Shared<ResourceManager> s_pointer =
nullptr;
80 unsigned int m_currentId = 1;
82 std::map<unsigned int, Resource> m_map{};
84 ResourceManager() =
default;