Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
Resource.h
Go to the documentation of this file.
1
2/*
3 ██╗ ██╗ █████╗ ████████╗ █████╗ ███╗ ██╗ █████╗
4 ██║ ██╔╝ ██╔══██╗ ╚══██╔══╝ ██╔══██╗ ████╗ ██║ ██╔══██╗
5 █████╔╝ ███████║ ██║ ███████║ ██╔██╗ ██║ ███████║
6 ██╔═██╗ ██╔══██║ ██║ ██╔══██║ ██║╚██╗██║ ██╔══██║
7 ██║ ██╗ ██║ ██║ ██║ ██║ ██║ ██║ ╚████║ ██║ ██║
8 ╚═╝ ╚═╝ ╚═╝ ╚═╝/\ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝
9 /vvvvvvvvvvvvvvvvvvv \=========================================,
10 `^^^^^^^^^^^^^^^^^^^ /---------------------------------------"
11 Katana Engine \/ © 2012 - Shuriken Studios LLC
12 http://www.shurikenstudios.com
13*/
14
15#pragma once
16
17namespace KatanaEngine
18{
19 class ResourceManager;
20
23 {
24 friend class ResourceManager;
25
26 public:
27
28 virtual ~Resource() { }
29
34 virtual bool Load(const std::string &path, ResourceManager *pManager) = 0;
35
38 unsigned short GetResourceID() const { return m_id; }
39
40
41 protected:
42
47 void Split(const std::string &line, const char delimeter, std::vector<std::string> &elements);
48
51 void ParseComments(std::string &line);
52
55 void TrimLine(std::string &line);
56
59 ResourceManager *GetResourceManager() { return m_pResourceManager; }
60
67 virtual bool IsCloneable() const = 0;
68
72 virtual Resource *Clone() { return this; };
73
74
75 private:
76
77 unsigned short m_id = 0;
78
79 ResourceManager *m_pResourceManager = nullptr;
80 };
81}
Base class for all resource types to be managed by the ResourceManager class.
Definition Resource.h:23
void Split(const std::string &line, const char delimeter, std::vector< std::string > &elements)
Splits a string into a vector of strings.
Definition Resource.cpp:19
virtual bool Load(const std::string &path, ResourceManager *pManager)=0
Load the desired resource into memory.
void TrimLine(std::string &line)
Removes white-space at the front and end of a line of text.
Definition Resource.cpp:46
unsigned short GetResourceID() const
Gets the ID of the resource.
Definition Resource.h:38
virtual bool IsCloneable() const =0
Used to determine if the resource is cloneable.
ResourceManager * GetResourceManager()
Gets a pointer to the ResourceManager that was used to load the resource.
Definition Resource.h:59
virtual Resource * Clone()
Clones a resource.
Definition Resource.h:72
void ParseComments(std::string &line)
Removes c-style, single-line comments from a line of text.
Definition Resource.cpp:34
Loads and manages the lifespan of objects from external files.
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...
Definition Animation.cpp:18