Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
ToyMaker::Resource< TDerived > Class Template Reference

The base class for any type whose creation and storage should be managed by the ResourceDatabase. More...

#include <resource_database.hpp>

Inheritance diagram for ToyMaker::Resource< TDerived >:
ToyMaker::IResource

Public Member Functions

std::string getResourceTypeName_ () const override
 Get the resource type string for this resource.
 
- Public Member Functions inherited from ToyMaker::IResource
virtual ~IResource ()=default
 Destroy the IResource object.
 

Protected Member Functions

 Resource (int explicitlyInitializeMe)
 Construct a new resource object.
 
- Protected Member Functions inherited from ToyMaker::IResource
 IResource ()=default
 Construct a new IResource object.
 

Static Private Member Functions

static void registerSelf ()
 A helper function that actually performs the task of registering this class with the ResourceDatabase.
 

Static Private Attributes

static Registrator< Resource< TDerived > > & s_registrator { Registrator<Resource<TDerived>>::getRegistrator() }
 A static variable to this classes Registrator.
 

Friends

class Registrator< Resource< TDerived > >
 

Additional Inherited Members

- Static Protected Member Functions inherited from ToyMaker::IResource
template<typename TResource>
static void RegisterResource ()
 Registers this resource as a Resource type with the ResourceDatabase.
 

Detailed Description

template<typename TDerived>
class ToyMaker::Resource< TDerived >

The base class for any type whose creation and storage should be managed by the ResourceDatabase.

References to a Resource are ultimately returned as shared pointers the the immediate subclass of this class.

Usage:

A class that wishes to be seen by the ResourceDatabase should have the following signature:

class Texture : public Resource<Texture> { // NOTE: TDerived derives from Resource<TDerived>
public:
// NOTE: Must have static function that names the resource
inline static std::string getResourceTypeName() { return "Texture"; }
GLuint textureID,
const ColorBufferDefinition& colorBufferDefinition,
const std::string& filepath
) :
Resource<Texture>{0}, // NOTE: Explicit call to Resource<TDerived>'s constructor
mID { textureID },
mFilepath { filepath },
mColorBufferDefinition{colorBufferDefinition}
{}
// ...
// ... The rest of the class' definition
// ...
};
The base class for any type whose creation and storage should be managed by the ResourceDatabase.
Definition resource_database.hpp:372
Resource(int explicitlyInitializeMe)
Construct a new resource object.
Definition resource_database.hpp:389
The class representation of textures on this engine, which are a type of Resource used both within an...
Definition texture.hpp:116
Texture(GLuint textureID, const ColorBufferDefinition &colorBufferDefinition, const std::string &filepath="")
Constructs a new texture object which takes ownership of an OpenGL texture handle and engine colorbuf...
Definition texture.cpp:40
A struct containing the definition of a color buffer, using which similar color buffers can be create...
Definition texture.hpp:30
Todo
Determine whether it is actually necessary to have all a Resource's construction and assignment operators defined when using the ResourceDatabase for something.
Template Parameters
TDerivedThe class that wishes to be exposed to ResourceDatabase.

Constructor & Destructor Documentation

◆ Resource()

template<typename TDerived>
ToyMaker::Resource< TDerived >::Resource ( int explicitlyInitializeMe)
inlineexplicitprotected

Construct a new resource object.

Parameters
explicitlyInitializeMeA dummy value which should have been removed long ago when the author discovered the explicit keyword.

Member Function Documentation

◆ getResourceTypeName_()

template<typename TDerived>
std::string ToyMaker::Resource< TDerived >::getResourceTypeName_ ( ) const
inlineoverridevirtual

Get the resource type string for this resource.

Remarks
Requires the derived type to implement a public static TDerived::getResourceTypeName() function.
Returns
std::string The resource type string for this resource.

Implements ToyMaker::IResource.

◆ registerSelf()

template<typename TDerived>
void ToyMaker::Resource< TDerived >::registerSelf ( )
staticprivate

A helper function that actually performs the task of registering this class with the ResourceDatabase.

This registration occurs during the static initialization phase of the program.

Member Data Documentation

◆ s_registrator

template<typename TDerived>
Registrator<Resource<TDerived> >& ToyMaker::Resource< TDerived >::s_registrator { Registrator<Resource<TDerived>>::getRegistrator() }
inlinestaticprivate

A static variable to this classes Registrator.

The registrator ensures that registerSelf() is called during the program's static initialization.

See also
Registrator<T>

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