diff --git a/src/force.cpp b/src/force.cpp index 6c9a42fbde..80803ee797 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -36,35 +36,10 @@ using namespace LAMMPS_NS; -// templates for factory functions: -// there will be one instance for each style keyword in the style_xxx.h file +// template for factory functions: +// there will be one instance for each style keyword in the respective style_xxx.h files -template static Pair *pair_creator(LAMMPS *lmp) -{ - return new T(lmp); -} - -template static Bond *bond_creator(LAMMPS *lmp) -{ - return new T(lmp); -} - -template static Angle *angle_creator(LAMMPS *lmp) -{ - return new T(lmp); -} - -template static Dihedral *dihedral_creator(LAMMPS *lmp) -{ - return new T(lmp); -} - -template static Improper *improper_creator(LAMMPS *lmp) -{ - return new T(lmp); -} - -template static KSpace *kspace_creator(LAMMPS *lmp) +template static S *style_creator(LAMMPS *lmp) { return new T(lmp); } @@ -111,7 +86,7 @@ void _noopt Force::create_factories() #define PAIR_CLASS #define PairStyle(key,Class) \ - (*pair_map)[#key] = &pair_creator; + (*pair_map)[#key] = &style_creator; #include "style_pair.h" // IWYU pragma: keep #undef PairStyle #undef PAIR_CLASS @@ -120,7 +95,7 @@ void _noopt Force::create_factories() #define BOND_CLASS #define BondStyle(key,Class) \ - (*bond_map)[#key] = &bond_creator; + (*bond_map)[#key] = &style_creator; #include "style_bond.h" // IWYU pragma: keep #undef BondStyle #undef BOND_CLASS @@ -129,7 +104,7 @@ void _noopt Force::create_factories() #define ANGLE_CLASS #define AngleStyle(key,Class) \ - (*angle_map)[#key] = &angle_creator; + (*angle_map)[#key] = &style_creator; #include "style_angle.h" // IWYU pragma: keep #undef AngleStyle #undef ANGLE_CLASS @@ -138,7 +113,7 @@ void _noopt Force::create_factories() #define DIHEDRAL_CLASS #define DihedralStyle(key,Class) \ - (*dihedral_map)[#key] = &dihedral_creator; + (*dihedral_map)[#key] = &style_creator; #include "style_dihedral.h" // IWYU pragma: keep #undef DihedralStyle #undef DIHEDRAL_CLASS @@ -147,7 +122,7 @@ void _noopt Force::create_factories() #define IMPROPER_CLASS #define ImproperStyle(key,Class) \ - (*improper_map)[#key] = &improper_creator; + (*improper_map)[#key] = &style_creator; #include "style_improper.h" // IWYU pragma: keep #undef ImproperStyle #undef IMPROPER_CLASS @@ -156,7 +131,7 @@ void _noopt Force::create_factories() #define KSPACE_CLASS #define KSpaceStyle(key,Class) \ - (*kspace_map)[#key] = &kspace_creator; + (*kspace_map)[#key] = &style_creator; #include "style_kspace.h" // IWYU pragma: keep #undef KSpaceStyle #undef KSPACE_CLASS diff --git a/src/modify.cpp b/src/modify.cpp index e3976f3622..2a192e9514 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -37,15 +37,10 @@ using namespace FixConst; #define DELTA 4 #define BIG 1.0e20 -// templates for factory functions: -// there will be one instance for each style keyword in the style_xxx.h file +// template for factory function: +// there will be one instance for each style keyword in the respective style_xxx.h files -template static Fix *fix_creator(LAMMPS *lmp, int narg, char **arg) -{ - return new T(lmp,narg,arg); -} - -template static Compute *compute_creator(LAMMPS *lmp, int narg, char **arg) +template static S *style_creator(LAMMPS *lmp, int narg, char **arg) { return new T(lmp,narg,arg); } @@ -106,7 +101,7 @@ void _noopt Modify::create_factories() #define FIX_CLASS #define FixStyle(key,Class) \ - (*fix_map)[#key] = &fix_creator; + (*fix_map)[#key] = &style_creator; #include "style_fix.h" // IWYU pragma: keep #undef FixStyle #undef FIX_CLASS @@ -117,7 +112,7 @@ void _noopt Modify::create_factories() #define COMPUTE_CLASS #define ComputeStyle(key,Class) \ - (*compute_map)[#key] = &compute_creator; + (*compute_map)[#key] = &style_creator; #include "style_compute.h" // IWYU pragma: keep #undef ComputeStyle #undef COMPUTE_CLASS