Jopnal Engine  alpha 0.4
Simple Component Based 2D/3D Game Engine
Public Member Functions | Protected Member Functions | Friends | List of all members
jop::Resource Class Referenceabstract

Base class for resources. More...

#include <Resource.hpp>

Inheritance diagram for jop::Resource:
jop::SafeReferenceable< Resource > jop::SerializeInfo jop::CollisionShape jop::CollisionShape2D jop::Font jop::Material jop::Mesh jop::Shader jop::ShaderProgram jop::SoundBuffer jop::Texture jop::TextureAtlas jop::TextureSampler

Public Member Functions

 Resource (const std::string &name)
 Constructor. More...
 
virtual ~Resource ()=0
 Virtual destructor. More...
 
const std::string & getName () const
 Get the name of this resource. More...
 
void setPersistence (const unsigned short level)
 Set the persistence level. More...
 
unsigned short getPersistence () const
 Get the persistence level. More...
 
- Public Member Functions inherited from jop::SafeReferenceable< Resource >
WeakReference< ResourcegetReference () const
 Get a weak reference to the bound object. More...
 
- Public Member Functions inherited from jop::SerializeInfo
 SerializeInfo ()
 
void setSerializePackage (const uint16 package)
 
uint16 getSerializePackage () const
 
void setShouldSerialize (const bool set)
 
bool shouldSerialize () const
 
void setLightSerializeable (const bool set)
 
bool isLightSerializeable () const
 

Protected Member Functions

 Resource (const Resource &other, const std::string &newName)
 Copy constructor. More...
 
- Protected Member Functions inherited from jop::SafeReferenceable< Resource >
 SafeReferenceable (Resource *ref)
 Constructor. More...
 
 SafeReferenceable (SafeReferenceable< Resource > &&other)
 Move constructor. More...
 
SafeReferenceableoperator= (SafeReferenceable< Resource > &&other)
 Move assignment operator. More...
 
 ~SafeReferenceable ()
 Protected destructor. More...
 

Friends

class ResourceManager
 

Detailed Description

Base class for resources.

Default & error resources

It's possible to define special resources in case of load failure, to be returned instead by jop::ResourceManager. To do so, define one or both of the following functions for your derived resource class:

static ResourceType& getDefault();
static ResourceType& getError();

If at least one of these exists, the resource manager will use them to fetch a fallback resource if the load() method fails. Make sure that these functions always succeed, so that they don't cause an infinite recursive loop.

Definition at line 37 of file Resource.hpp.

Constructor & Destructor Documentation

jop::Resource::Resource ( const Resource other,
const std::string &  newName 
)
protected

Copy constructor.

This differs from the standard copy constructor signature. Should you wish your custom resources to be copyable via the resource manager, you should define a copy constructor with an similar signature.

Parameters
otherThe other resource to copy
newNameNew name for this resource
jop::Resource::Resource ( const std::string &  name)

Constructor.

Parameters
nameName of the resource. This must be the file path if this resource is loaded from a file.
virtual jop::Resource::~Resource ( )
pure virtual

Virtual destructor.

Member Function Documentation

const std::string& jop::Resource::getName ( ) const

Get the name of this resource.

Returns
Reference to the name
unsigned short jop::Resource::getPersistence ( ) const

Get the persistence level.

Returns
The persistence level
See also
setPersistence()
void jop::Resource::setPersistence ( const unsigned short  level)

Set the persistence level.

The persistence level controls how resources are unloaded by the resource manager.

Parameters
levelThe persistence level
See also
ResourceManager

Friends And Related Function Documentation

friend class ResourceManager
friend

Definition at line 43 of file Resource.hpp.


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