SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::core::GameObjectRegistry Class Referencefinal

A registry used to create GameObject instances and get serialization objects for it. More...

#include <Registries.h>

Inheritance diagram for spark::core::GameObjectRegistry:
spark::patterns::Factory< std::string, core::GameObject, std::string, core::GameObject * >

Public Member Functions

 GameObjectRegistry ()
 Instantiate a new GameObjectRegistry with the default GameObject types.
 
template<typename T >
requires std::derived_from<T, core::GameObject>
void registerType ()
 Registers a new GameObject into the registry.
 
- Public Member Functions inherited from spark::patterns::Factory< std::string, core::GameObject, std::string, core::GameObject * >
 Factory (const Factory &other)=delete
 
 Factory (Factory &&other) noexcept=default
 
Factoryoperator= (const Factory &other)=delete
 
Factoryoperator= (Factory &&other) noexcept=default
 
void registerType (const std::string &key)
 Registers a type the factory can create.
 
BasePtr create (const std::string &key, Args &&... args) const
 Creates an object of type BaseType. Throws an exception if the type is not registered.
 
BasePtr createOrFail (const std::string &key, Args &&... args) const noexcept
 Creates an object of type BaseType.
 
std::vector< std::string > registeredTypes () const noexcept
 Gets a vector of all registered types in the factory.
 

Additional Inherited Members

- Public Types inherited from spark::patterns::Factory< std::string, core::GameObject, std::string, core::GameObject * >
using BasePtr
 
using CreatorPtr
 

Detailed Description

A registry used to create GameObject instances and get serialization objects for it.

This is a factory used to deserialize game objects instances from a game save.

Member Function Documentation

◆ registerType()

template<typename T >
requires std::derived_from<T, core::GameObject>
void spark::core::GameObjectRegistry::registerType ( )

Registers a new GameObject into the registry.

Template Parameters
TThe type of the GameObject to register.