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::ResourceFactory< TResource > Class Template Reference

Tracks pointers to all ResourceConstructors responsible for creating a resource of one type. More...

#include <resource_database.hpp>

Inheritance diagram for ToyMaker::ResourceFactory< TResource >:
ToyMaker::IResourceFactory

Public Member Functions

 ResourceFactory ()
 Construct a new Resource Factory object.
 
- Public Member Functions inherited from ToyMaker::IResourceFactory
virtual ~IResourceFactory ()=default
 Destroy the IResourceFactory object.
 

Private Member Functions

std::shared_ptr< IResourcecreateResource (const nlohmann::json &resourceDescription) override
 Create an object of type Resource, specifying its constructor and the constructor's parameters in JSON.
 

Additional Inherited Members

- Protected Attributes inherited from ToyMaker::IResourceFactory
std::map< std::string, std::unique_ptr< IResourceConstructor > > mFactoryMethods {}
 A list of constructors that may be used to create a Resource of this kind.
 

Detailed Description

template<typename TResource>
class ToyMaker::ResourceFactory< TResource >

Tracks pointers to all ResourceConstructors responsible for creating a resource of one type.

An object of this kind is created automatically when a resource type registers itself for management by the ResourceDatabase.

Template Parameters
TResourceThe resource this factory can create.

Member Function Documentation

◆ createResource()

template<typename TResource>
std::shared_ptr< IResource > ToyMaker::ResourceFactory< TResource >::createResource ( const nlohmann::json & resourceDescription)
overrideprivatevirtual

Create an object of type Resource, specifying its constructor and the constructor's parameters in JSON.

Parameters
resourceDescriptionA JSON description containing the resource constructor's name and parameters.
Returns
std::shared_ptr<IResource> A shared pointer to the base class of the Resource.

Implements ToyMaker::IResourceFactory.


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