![]() |
smgl 0.11.0
Structured Metadata Engine and Graph Objects Library
|
Abstract Factory class. More...
Public Types | |
| using | IDType = IdentifierType |
Public Member Functions | |
| void | Reserve (std::size_t count) |
| void | ReserveAdditional (std::size_t count) |
| bool | Register (const IDType &id, ProductCreator creator, const std::type_info &info) |
| bool | Deregister (const IDType &id) |
| bool | IsRegistered (const IDType &id) |
| bool | IsRegistered (const std::type_info &info) |
| AbstractProduct | CreateObject (const IDType &id) |
| IDType | GetTypeIdentifier (const std::type_info &info) |
| std::vector< IDType > | GetRegisteredIdentifiers () const |
Private Types | |
| using | NameMap = std::unordered_map< size_t, IdentifierType > |
| using | TypeMap = std::unordered_map< IdentifierType, ProductCreator > |
Private Attributes | |
| NameMap | typeToIDMap_ |
| TypeMap | idToCreatorMap_ |
Abstract Factory class.
This factory uses RTTI to allow looking up an existing object's registered type identifier.
| BaseClass | Base type of object managed by factory |
| IdentifierType | Identifier type (e.g. std::string) |
| AbstractProduct | Product generated by factory creation method |
| ProductCreator | Type of functor which produces AbstractProduct |
| FactoryErrorPolicy | Policy for handling errors |
Definition at line 73 of file Factory.hpp.
| using smgl::detail::Factory< BaseClass, IdentifierType, AbstractProduct, ProductCreator, FactoryErrorPolicy >::IDType = IdentifierType |
Convenience alias for identifiers
Definition at line 77 of file Factory.hpp.
|
private |
Alias for std::type_info::hash() -> IdentifierType structure
Definition at line 109 of file Factory.hpp.
|
private |
Alias for IdentifierType -> ProduceCreator structure
Definition at line 111 of file Factory.hpp.
| A smgl::detail::Factory< B, I, A, P, E >::CreateObject | ( | const IDType & | id | ) |
Create AbstractProduct from registered identifier
Definition at line 111 of file FactoryImpl.hpp.
| bool smgl::detail::Factory< B, I, A, P, E >::Deregister | ( | const IDType & | id | ) |
Deregister type using identifier
Definition at line 88 of file FactoryImpl.hpp.
| std::vector< I > smgl::detail::Factory< B, I, A, P, E >::GetRegisteredIdentifiers | ( | ) | const |
Get a list of registered identifiers
Definition at line 142 of file FactoryImpl.hpp.
| I smgl::detail::Factory< B, I, A, P, E >::GetTypeIdentifier | ( | const std::type_info & | info | ) |
Get a registered type's identifier
Definition at line 126 of file FactoryImpl.hpp.
| bool smgl::detail::Factory< B, I, A, P, E >::IsRegistered | ( | const IDType & | id | ) |
Check whether given ID is registered to a type
Definition at line 158 of file FactoryImpl.hpp.
| bool smgl::detail::Factory< B, I, A, P, E >::IsRegistered | ( | const std::type_info & | info | ) |
Check whether a given type has been registered
Definition at line 170 of file FactoryImpl.hpp.
| bool smgl::detail::Factory< B, I, A, P, E >::Register | ( | const IDType & | id, |
| ProductCreator | creator, | ||
| const std::type_info & | info | ||
| ) |
Register identifier, type, and creation functor
Definition at line 68 of file FactoryImpl.hpp.
| void smgl::detail::Factory< B, I, A, P, E >::Reserve | ( | std::size_t | count | ) |
Reserve space for exactly N registrations
Definition at line 42 of file FactoryImpl.hpp.
| void smgl::detail::Factory< B, I, A, P, E >::ReserveAdditional | ( | std::size_t | count | ) |
Reserve space for an additional N registrations
Definition at line 55 of file FactoryImpl.hpp.
|
private |
Holds mappings from IdentifierType -> ProduceCreator
Definition at line 115 of file Factory.hpp.
|
private |
Holds mappings from std::type_info::hash() -> IdentifierType
Definition at line 113 of file Factory.hpp.