|
SPARK
0.1.0
A general purpose game engine written in C++.
|
A factory class that creates objects of type BaseType. More...
#include <Factory.h>
Public Types | |
| using | BasePtr = std::unique_ptr<BaseType> |
| using | CreatorPtr = std::unique_ptr<details::BaseCreator<BaseType, Args...>> |
Public Member Functions | |
| Factory (const Factory &other)=delete | |
| Factory (Factory &&other) noexcept=default | |
| Factory & | operator= (const Factory &other)=delete |
| Factory & | operator= (Factory &&other) noexcept=default |
| template<typename TypeToRegister > | |
| void | registerType (const Key &key) |
| Registers a type the factory can create. | |
| BasePtr | create (const Key &key, Args &&... args) const |
| Creates an object of type BaseType. Throws an exception if the type is not registered. | |
| BasePtr | createOrFail (const Key &key, Args &&... args) const noexcept |
| Creates an object of type BaseType. | |
| std::vector< Key > | registeredTypes () const noexcept |
| Gets a vector of all registered types in the factory. | |
A factory class that creates objects of type BaseType.
| Key | The type of the key used to reference objects. |
| BaseType | The type of the base class. |
| Args | The types of the arguments passed to the constructor of the derived class. |
|
nodiscard |
Creates an object of type BaseType. Throws an exception if the type is not registered.
| key | The key of type Key used to create the object. |
| args | The arguments passed to the constructor of the derived class. |
| spark::base::BadArgumentException | when requested type is not registered. |
|
nodiscardnoexcept |
Creates an object of type BaseType.
| key | The key of type Key used to create the object. |
| args | The arguments passed to the constructor of the derived class. |
|
nodiscardnoexcept |
Gets a vector of all registered types in the factory.
| void spark::patterns::Factory< Key, BaseType, Args >::registerType | ( | const Key & | key | ) |
Registers a type the factory can create.
| TypeToRegister | The type of the derived class to register. |
| key | The key used to reference the object. |
| spark::base::BadArgumentException | when type is already registered. |