Arcade Shooter
Resource.h
1 
2 /* ██╗ ██╗ █████╗ ████████╗ █████╗ ███╗ ██╗ █████╗
3  ██║ ██╔╝ ██╔══██╗ ╚══██╔══╝ ██╔══██╗ ████╗ ██║ ██╔══██╗
4  █████╔╝ ███████║ ██║ ███████║ ██╔██╗ ██║ ███████║
5  ██╔═██╗ ██╔══██║ ██║ ██╔══██║ ██║╚██╗██║ ██╔══██║
6  ██║ ██╗ ██║ ██║ ██║ ██║ ██║ ██║ ╚████║ ██║ ██║
7  ╚═╝ ╚═╝ ╚═╝ ╚═╝/\ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝
8  /vvvvvvvvvvvvvvvvvvv \=========================================,
9  `^^^^^^^^^^^^^^^^^^^ /---------------------------------------"
10  Katana Engine \/ © 2012 - Shuriken Studios LLC */
11 
12 #pragma once
13 
14 namespace KatanaEngine
15 {
16  class ResourceManager;
17 
19  class Resource
20  {
21  friend class ResourceManager;
22 
23  public:
24 
25  virtual ~Resource() { }
26 
31  virtual bool Load(const std::string &path, ResourceManager *pManager) = 0;
32 
35  unsigned short GetResourceID() const { return m_id; }
36 
37 
38  protected:
39 
44  void Split(const std::string &line, const char delimeter, std::vector<std::string> &elements);
45 
48  void ParseComments(std::string &line);
49 
52  void TrimLine(std::string &line);
53 
56  ResourceManager *GetResourceManager() { return m_pResourceManager; }
57 
64  virtual bool IsCloneable() const = 0;
65 
69  virtual Resource *Clone() { return this; };
70 
71 
72  private:
73 
74  unsigned short m_id;
75 
76  ResourceManager *m_pResourceManager;
77  };
78 }
ResourceManager * GetResourceManager()
Gets a pointer to the ResourceManager that was used to load the resource.
Definition: Resource.h:56
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:43
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:16
virtual bool IsCloneable() const =0
Used to determine if the resource is cloneable.
Base class for all resource types to be managed by the ResourceManager class.
Definition: Resource.h:19
unsigned short GetResourceID() const
Gets the ID of the resource.
Definition: Resource.h:35
void ParseComments(std::string &line)
Removes c-style, single-line comments from a line of text.
Definition: Resource.cpp:31
Loads and manages the lifespan of objects from external files.
Definition: ResourceManager.h:17
virtual Resource * Clone()
Clones a resource.
Definition: Resource.h:69
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...
Definition: Animation.cpp:14