Norbert's Game Engine v200
Loading...
Searching...
No Matches
eFactory< T > Class Template Reference

#include <Factory.hpp>

Inheritance diagram for eFactory< T >:
eBase

Public Member Functions

template<typename Y >
void Register ()
 
std::unique_ptr< T > CreateObject (eString name)
 
bool ClassExists (eString name)
 
std::unordered_map< strg, std::function< std::unique_ptr< T >()> > & GetCollection ()
 
- Public Member Functions inherited from eBase
template<typename T >
T * Cast (eBase *obj)
 Cast class to base.
 

Detailed Description

template<typename T>
class eFactory< T >

Factory class for object

Definition at line 13 of file Factory.hpp.

Member Function Documentation

◆ ClassExists()

template<typename T >
bool eFactory< T >::ClassExists ( eString name)
inline

Definition at line 36 of file Factory.hpp.

37 {
38 auto it = mItems.find(name.GetStrg());
39 if (it != mItems.end())
40 return true;
41 return false;
42 }
const strg & GetStrg() const
Return text as std::string.
Definition String.cpp:70

◆ CreateObject()

template<typename T >
std::unique_ptr< T > eFactory< T >::CreateObject ( eString name)
inline

Definition at line 27 of file Factory.hpp.

28 {
29 auto it = mItems.find(name.GetStrg());
30 if (it != mItems.end())
31 return (it->second)();
32 return nullptr;
33 }

◆ GetCollection()

template<typename T >
std::unordered_map< strg, std::function< std::unique_ptr< T >()> > & eFactory< T >::GetCollection ( )
inline

Definition at line 45 of file Factory.hpp.

46 {
47 return mItems;
48 }

◆ Register()

template<typename T >
template<typename Y >
void eFactory< T >::Register ( )
inline

Definition at line 18 of file Factory.hpp.

19 {
20 mItems[typeid(Y).name()] = []() -> std::unique_ptr<T> {
21 return std::make_unique<Y>();
22 };
23 return;
24 }

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