Castor3D 0.16.0
Multiplatform 3D engine
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT > Class Template Reference

Factory concept implementation. More...

#include <Factory.hpp>

Inheritance diagram for castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >:
Inheritance graph
[legend]

Classes

struct  ListEntry
 

Public Types

using Obj = ObjT
 
using Key = KeyT
 
using Entry = EntryT
 
using Id = IdT
 
using PtrType = PtrTypeT
 
using Creator = CreatorT
 
using ObjPtr = PtrType
 
using ObjCont = Vector< Entry >
 

Public Member Functions

EntryregisterType (Key const &key, Creator create)
 Registers an object type.
 
void unregisterType (Key const &key)
 Unregisters an object type.
 
Id getTypeId (Key const &key) const
 
Key getIdType (Id const &id) const
 
bool isTypeRegistered (Key const &key) const
 Checks if the given object type is registered.
 
Vector< ListEntrylistRegisteredTypes () const
 
template<typename ... Parameters>
ObjPtr create (Key const &key, Parameters &&... params) const
 Creates an object from a key.
 

Protected Attributes

Id m_currentId {}
 
ObjCont m_registered
 

Detailed Description

template<class ObjT, class KeyT, class PtrTypeT, typename CreatorT, class IdT, class EntryT>
class castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >

Factory concept implementation.

Member Typedef Documentation

◆ Creator

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
using castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::Creator = CreatorT

◆ Entry

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
using castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::Entry = EntryT

◆ Id

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
using castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::Id = IdT

◆ Key

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
using castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::Key = KeyT

◆ Obj

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
using castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::Obj = ObjT

◆ ObjCont

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
using castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::ObjCont = Vector< Entry >

◆ ObjPtr

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
using castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::ObjPtr = PtrType

◆ PtrType

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
using castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::PtrType = PtrTypeT

Member Function Documentation

◆ create()

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
template<typename ... Parameters>
ObjPtr castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::create ( Key const & key,
Parameters &&... params ) const
inline

Creates an object from a key.

Parameters
[in]keyThe object type
[in]paramsThe creation parameters
Returns
The created object

References CU_Exception, castor::ERROR_UNKNOWN_OBJECT, and castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::m_registered.

Referenced by castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::registerType().

Here is the caller graph for this function:

◆ getIdType()

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
Key castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::getIdType ( Id const & id) const
inline
Parameters
[in]idThe object type ID.
Returns
The object type.

References castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::m_registered.

◆ getTypeId()

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
Id castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::getTypeId ( Key const & key) const
inline
Parameters
[in]keyThe object type.
Returns
The object type ID.

References castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::m_registered.

◆ isTypeRegistered()

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
bool castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::isTypeRegistered ( Key const & key) const
inline

Checks if the given object type is registered.

Parameters
[in]keyThe object type.
Returns
true if registered.

References castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::m_registered.

◆ listRegisteredTypes()

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
Vector< ListEntry > castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::listRegisteredTypes ( ) const
inline
Returns
Retrieves the registered types list.

References castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::m_registered.

◆ registerType()

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
Entry & castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::registerType ( Key const & key,
Creator create )
inline

Registers an object type.

Parameters
[in]keyThe object type
[in]createThe object creation function

References castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::create(), castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::m_currentId, and castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::m_registered.

Here is the call graph for this function:

◆ unregisterType()

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
void castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::unregisterType ( Key const & key)
inline

Unregisters an object type.

Parameters
[in]keyThe object type

References castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::m_registered.

Member Data Documentation

◆ m_currentId

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
Id castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::m_currentId {}
protected

◆ m_registered

template<class ObjT , class KeyT , class PtrTypeT , typename CreatorT , class IdT , class EntryT >
ObjCont castor::Factory< ObjT, KeyT, PtrTypeT, CreatorT, IdT, EntryT >::m_registered
protected

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