Comments refactoring.

This commit is contained in:
DH
2026-02-27 19:25:13 -05:00
parent 4ef52a954b
commit 063292c7ed

View File

@@ -4,7 +4,11 @@
#include <memory>
/**
* @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 ClassId, class BaseClass, class ... Args>
class TypeFsactory {
public:
/**
* @brief BaseClass_SP - base class shared pointer type
*/
typedef std::shared_ptr<BaseClass> BaseClass_SP;
/**
* @brief typefactoryFunction - typefactory function pointer type. Generally speaking it is pointer to constructor.
@@ -76,7 +77,7 @@ class TypeFsactory {
*/
template<class Derived>
void registerType (const ClassId& id) {
/// store pointer to constructor of Derived class
/// Register Derived type by storing its constructor wrapper
classes[id] = &typefactory<Derived>;
}
@@ -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<ClassId, typefactoryFunction> classes;