diff --git a/typefactory/typefactory.h b/typefactory/typefactory.h index aea5944..ff95070 100644 --- a/typefactory/typefactory.h +++ b/typefactory/typefactory.h @@ -4,7 +4,11 @@ #include /** - * @brief The TypeFsactory class - base typefactory (abstract factory) template + * @brief Registry-based factory for creating objects by runtime identifier. + * + * Allows registering derived types and instantiating them + * using a ClassId key. + * * @param ClassId - unique class identification class. For example string, or integer id. * @param BaseClass - all objects should have one base class. For example vehicle or parameter * @param Args - constructor arguments @@ -52,9 +56,6 @@ template class TypeFsactory { public: - /** - * @brief BaseClass_SP - base class shared pointer type - */ typedef std::shared_ptr BaseClass_SP; /** * @brief typefactoryFunction - typefactory function pointer type. Generally speaking it is pointer to constructor. @@ -76,7 +77,7 @@ class TypeFsactory { */ template void registerType (const ClassId& id) { - /// store pointer to constructor of Derived class + /// Register Derived type by storing its constructor wrapper classes[id] = &typefactory; } @@ -87,12 +88,11 @@ class TypeFsactory { * @throws std::out_of_range when id not found in map */ typefactoryFunction createInstance (const ClassId& id) const { - /// constructor of registered type will call here return classes.at (id); } protected: /** - * @brief classes - main storage for pointers to constructors of registered types + * @brief classes - Not thread-safe. Register types during initialization phase only. */ std::unordered_map classes;