Remove _T postfix. No reference
This commit is contained in:
@@ -5,20 +5,20 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The TypeFsactory class - base typefactory (abstract factory) template
|
* @brief The TypeFsactory class - base typefactory (abstract factory) template
|
||||||
* @param ClassId_T - unique class identification class. For example string, or integer id.
|
* @param ClassId - unique class identification class. For example string, or integer id.
|
||||||
* @param BaseClass_T - all objects should have one base class. For example vehicle or parameter
|
* @param BaseClass - all objects should have one base class. For example vehicle or parameter
|
||||||
* @param Args - constructor arguments
|
* @param Args - constructor arguments
|
||||||
*
|
*
|
||||||
* Usage example:
|
* Usage example:
|
||||||
* @code
|
* @code
|
||||||
* class Base_T {
|
* class Base {
|
||||||
* public:
|
* public:
|
||||||
* virtual int get() = 0;
|
* virtual int get() = 0;
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* class Derived1_T : public Base_T {
|
* class Derived1 : public Base {
|
||||||
* public:
|
* public:
|
||||||
* Derived1_T (int start) : m_start(start){}
|
* Derived1 (int start) : m_start(start){}
|
||||||
* int get() override {
|
* int get() override {
|
||||||
* return m_start + 1;
|
* return m_start + 1;
|
||||||
* }
|
* }
|
||||||
@@ -26,9 +26,9 @@
|
|||||||
* int m_start = 0;
|
* int m_start = 0;
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* class Derived2_T : public Base_T {
|
* class Derived2 : public Base {
|
||||||
* public:
|
* public:
|
||||||
* Derived1_T (int start) : m_start(start){}
|
* Derived1 (int start) : m_start(start){}
|
||||||
* int get() override {
|
* int get() override {
|
||||||
* return m_start + 2;
|
* return m_start + 2;
|
||||||
* }
|
* }
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
* .
|
* .
|
||||||
* .
|
* .
|
||||||
* .
|
* .
|
||||||
* TypeFsactory <std::string, Base_T, int> typefactory;
|
* TypeFsactory <std::string, Base, int> typefactory;
|
||||||
* typefactory.registerType<Derived1>("one");
|
* typefactory.registerType<Derived1>("one");
|
||||||
* typefactory.registerType<Derived2>("2");
|
* typefactory.registerType<Derived2>("2");
|
||||||
*
|
*
|
||||||
@@ -49,13 +49,13 @@
|
|||||||
* d2->get();
|
* d2->get();
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
template<class ClassId_T, class BaseClass_T, class ... Args>
|
template<class ClassId, class BaseClass, class ... Args>
|
||||||
class TypeFsactory {
|
class TypeFsactory {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief BaseClass_SP - base class shared pointer type
|
* @brief BaseClass_SP - base class shared pointer type
|
||||||
*/
|
*/
|
||||||
typedef std::shared_ptr<BaseClass_T> BaseClass_SP;
|
typedef std::shared_ptr<BaseClass> BaseClass_SP;
|
||||||
/**
|
/**
|
||||||
* @brief typefactoryFunction - typefactory function pointer type. Generally speaking it is pointer to constructor.
|
* @brief typefactoryFunction - typefactory function pointer type. Generally speaking it is pointer to constructor.
|
||||||
*/
|
*/
|
||||||
@@ -75,7 +75,7 @@ class TypeFsactory {
|
|||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
template<class Derived>
|
template<class Derived>
|
||||||
void registerType (const ClassId_T& id) {
|
void registerType (const ClassId& id) {
|
||||||
/// store pointer to constructor of Derived class
|
/// store pointer to constructor of Derived class
|
||||||
classes[id] = &typefactory<Derived>;
|
classes[id] = &typefactory<Derived>;
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ class TypeFsactory {
|
|||||||
* @return shared pointer to new class.
|
* @return shared pointer to new class.
|
||||||
* @throws std::out_of_range when id not found in map
|
* @throws std::out_of_range when id not found in map
|
||||||
*/
|
*/
|
||||||
typefactoryFunction create (const ClassId_T& id) const {
|
typefactoryFunction create (const ClassId& id) const {
|
||||||
/// constructor of registered type will call here
|
/// constructor of registered type will call here
|
||||||
return classes.at (id);
|
return classes.at (id);
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ class TypeFsactory {
|
|||||||
/**
|
/**
|
||||||
* @brief classes - main storage for pointers to constructors of registered types
|
* @brief classes - main storage for pointers to constructors of registered types
|
||||||
*/
|
*/
|
||||||
std::unordered_map<ClassId_T, typefactoryFunction> classes;
|
std::unordered_map<ClassId, typefactoryFunction> classes;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user