Arcade Shooter
Public Member Functions | Protected Member Functions | Friends | List of all members
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:
KatanaEngine::Animation KatanaEngine::Font KatanaEngine::Texture KatanaEngine::RenderTarget

Public Member Functions

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

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. More...
 
void ParseComments (std::string &line)
 Removes c-style, single-line comments from a line of text. More...
 
void TrimLine (std::string &line)
 Removes white-space at the front and end of a line of text. More...
 
ResourceManagerGetResourceManager ()
 Gets a pointer to the ResourceManager that was used to load the resource. More...
 
virtual bool IsCloneable () const =0
 Used to determine if the resource is cloneable. More...
 
virtual ResourceClone ()
 Clones a resource. More...
 

Friends

class ResourceManager
 

Detailed Description

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

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.

◆ GetResourceID()

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

Gets the ID of the resource.

Returns
The id of the resource.

◆ 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.

◆ 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::Font, KatanaEngine::Texture, and KatanaEngine::Animation.

◆ 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::Font, KatanaEngine::RenderTarget, KatanaEngine::Animation, 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.

◆ 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.

◆ 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.

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