The FactoryTemplate may be used to quickly create default factories that are only used for item creation without any further logic.
More...
#include "FactoryTemplate.h"
template<class ValueType>
class ot::FactoryTemplate< ValueType >
The FactoryTemplate may be used to quickly create default factories that are only used for item creation without any further logic.
- Note
- Note that the createFromJson() methods will call setFromJsonObject() if the created item inherits from Serializable. The key for creating an object is a std::string.
- Template Parameters
-
ValueType | Value type (e.g. MyClass). |
◆ ConstructorFunctionType
template<class ValueType >
Constructor type definition.
◆ FactoryTemplate()
template<class ValueType >
◆ ~FactoryTemplate()
template<class ValueType >
◆ createFromJSON() [1/2]
template<class ValueType >
Creates an instance according to the key in the provided JSON object. If the key is empty the request will be ignored. If the created instance inherits from Serializable the setFromJsonObject method will be called.
- Parameters
-
_jsonObject | The JSON object containing the key and optionally additional information. |
_typeKey | The JSON object key by which the constructor key may be retreived. |
◆ createFromJSON() [2/2]
template<class ValueType >
◆ createFromKey()
template<class ValueType >
Call the constructor for the given key and return the created instance.
- Parameters
-
◆ deregisterConstructor()
template<class ValueType >
Remove the constructor for the given key.
- Parameters
-
◆ registerConstructor()
template<class ValueType >
Will register the prvided constructor under the given key. If a constructor for the given key already exists a warning log will be generated and the request will be ignored.
- Parameters
-
_key | The constructor key. |
_constructor | The constructor. |
The documentation for this class was generated from the following files: