Template Class multifactory

Class Documentation

template<typename TType, template<class WrappedTBase, typename...> class TPointerWrapper, typename TBase>
class multifactory

A factory that releases or shares ownership of the created objects to the class/context that requests object creation. Derived types do not have to hve compatible constructor signatures. HOWEVER, though this class can handle heterogenous constructor signatures, you will likely need a switch() to determine what parameters to pass based on the name of the thing you want to build, thus defeating the purpose of a factory to some degree.

Template Parameters:
  • TType – The type of the factory.

  • TBase – Type of objects capable of creation from this factory (restricted to this type and its derived types).

  • TPointerWrapper – std::shared_ptr or std::unique_ptr.

Public Functions

multifactory(void) = default
virtual ~multifactory(void) = default
template<typename TDerived, typename ...Args>
inline TPointerWrapper<TBase> create(const std::string &name, Args... args)
template<typename TDerived, typename ...Args>
inline void register_type(const std::string &name)

Register a type with the factory, and associate it with the specified name.

The type to register must be derived from the factory base class.