![]() |
ImFusion SDK 4.3
|
#include <ImFusion/ML/GenericFactory.h>
Generic factory class for registering polymorphic types Usage: More...
Generic factory class for registering polymorphic types Usage:
In this situation you can register DerivedItems as follow: 1) Using the direct constructor:
2) Using a builder function:
Public Types | |
| using | CreatorRegistry = std::unordered_map<std::string, detail::Creator<Base, Params...>*> |
| template<typename Derived> | |
| using | Builder = typename detail::CreatorImpl<Derived, Base, Params...>::BuilderFunc |
Public Member Functions | |
| virtual std::unique_ptr< Base > | create (const std::string &name, Params &&... params) const |
| virtual std::vector< std::string > | availableTypes () const |
| virtual bool | hasType (const std::string &name) const |
| template<typename Derived> | |
| void | registerType (const std::string &name, Builder< Derived > builder) |
| register a creator function associated to a specific key | |
| template<typename Derived, typename = typename std::enable_if<std::is_constructible<Derived, Params...>::value>::type> | |
| void | registerType (const std::string &name) |
| Sfinae based register function for registration of object that can be directly constructed from Params... | |
| void | setVerbose (bool verbose) |
| void | setAllowReplacement (bool allowReplacement) |
Protected Attributes | |
| CreatorRegistry | m_registry |
| bool | m_allowReplacement = false |
| Allow re-registration of types. This is useful for the case where one wants to reload a python op. | |
| bool | m_verbose = false |