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

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

#include <Registries.h>

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

Public Member Functions

 ComponentRegistry ()
 Instantiate a new ComponentRegistry with the default Component types.
 
template<typename T >
requires std::derived_from<T, core::Component>
void registerType ()
 Registers a new Component into the registry.
 
- Public Member Functions inherited from spark::patterns::Factory< std::string, core::Component, 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::Component, core::GameObject * >
using BasePtr
 
using CreatorPtr
 

Detailed Description

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

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

Member Function Documentation

◆ registerType()

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

Registers a new Component into the registry.

Template Parameters
TThe type of the Component to register.