Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
KatanaEngine::Resource Class Referenceabstract

Base class for all resource types to be managed by the ResourceManager class. More...

#include <Resource.h>

Inheritance diagram for KatanaEngine::Resource:

Public Member Functions

virtual ~Resource ()
 
virtual bool Load (const std::string &path, ResourceManager *pManager)=0
 Load the desired resource into memory.
 
unsigned short GetResourceID () const
 Gets the ID of the resource.
 

Protected Member Functions

void Split (const std::string &line, const char delimeter, std::vector< std::string > &elements)
 Splits a string into a vector of strings.
 
void ParseComments (std::string &line)
 Removes c-style, single-line comments from a line of text.
 
void TrimLine (std::string &line)
 Removes white-space at the front and end of a line of text.
 
ResourceManagerGetResourceManager ()
 Gets a pointer to the ResourceManager that was used to load the resource.
 
virtual bool IsCloneable () const =0
 Used to determine if the resource is cloneable.
 
virtual ResourceClone ()
 Clones a resource.
 

Friends

class ResourceManager
 

Detailed Description

Base class for all resource types to be managed by the ResourceManager class.

Definition at line 22 of file Resource.h.

Constructor & Destructor Documentation

◆ ~Resource()

virtual KatanaEngine::Resource::~Resource ( )
inlinevirtual

Definition at line 28 of file Resource.h.

Member Function Documentation

◆ Clone()

virtual Resource * KatanaEngine::Resource::Clone ( )
inlineprotectedvirtual

Clones a resource.

Returns
Returns a pointer to a clone if the resource is cloneable. Otherwise a pointer to "this" is returned.

Reimplemented in KatanaEngine::Animation.

Definition at line 72 of file Resource.h.

◆ GetResourceID()

unsigned short KatanaEngine::Resource::GetResourceID ( ) const
inline

Gets the ID of the resource.

Returns
The id of the resource.

Definition at line 38 of file Resource.h.

◆ GetResourceManager()

ResourceManager * KatanaEngine::Resource::GetResourceManager ( )
inlineprotected

Gets a pointer to the ResourceManager that was used to load the resource.

Returns
Returns a pointer to the ResourceManager.

Definition at line 59 of file Resource.h.

◆ IsCloneable()

virtual bool KatanaEngine::Resource::IsCloneable ( ) const
protectedpure virtual

Used to determine if the resource is cloneable.

Returns
Returns true if the resource is clonable, false otherwise.
Remarks
Resources that are stateless should not be cloneable; i.e. Fonts, Textures, etc. Resources that do contain state should be cloned to prevent state duplication. For example, an Animation that is shared (not cloned) would share the current frame. This would mean that they would always be playing in sync.

Implemented in KatanaEngine::Animation, KatanaEngine::AudioSample, KatanaEngine::Font, and KatanaEngine::Texture.

◆ Load()

virtual bool KatanaEngine::Resource::Load ( const std::string & path,
ResourceManager * pManager )
pure virtual

Load the desired resource into memory.

Parameters
pathThe path to the desired resource.
pManagerA pointer to the ResourceManager that will manage the resource.
Returns
Returns true if the resource was loaded, false otherwise.

Implemented in KatanaEngine::Animation, KatanaEngine::AudioSample, KatanaEngine::Font, KatanaEngine::RenderTarget, and KatanaEngine::Texture.

◆ ParseComments()

void KatanaEngine::Resource::ParseComments ( std::string & line)
protected

Removes c-style, single-line comments from a line of text.

Parameters
lineThe line to remove the comments from.

Definition at line 34 of file Resource.cpp.

◆ Split()

void KatanaEngine::Resource::Split ( const std::string & line,
const char delimeter,
std::vector< std::string > & elements )
protected

Splits a string into a vector of strings.

Parameters
lineThe string that will be split.
delimeterThe character that will determine the split locations.
elementsThe vector where the split string elements will be stored.

Definition at line 19 of file Resource.cpp.

◆ TrimLine()

void KatanaEngine::Resource::TrimLine ( std::string & line)
protected

Removes white-space at the front and end of a line of text.

Parameters
lineThe line to remove the white-space from.

Definition at line 46 of file Resource.cpp.

Friends And Related Symbol Documentation

◆ ResourceManager

friend class ResourceManager
friend

Definition at line 24 of file Resource.h.


The documentation for this class was generated from the following files: