diff --git a/src/force.cpp b/src/force.cpp index 333a6e4715..6c9a42fbde 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -36,6 +36,39 @@ using namespace LAMMPS_NS; +// templates for factory functions: +// there will be one instance for each style keyword in the style_xxx.h file + +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) +{ + return new T(lmp); +} + /* ---------------------------------------------------------------------- */ Force::Force(LAMMPS *lmp) : Pointers(lmp) @@ -280,16 +313,6 @@ Pair *Force::new_pair(const std::string &style, int trysuffix, int &sflag) return nullptr; } -/* ---------------------------------------------------------------------- - one instance per pair style in style_pair.h -------------------------------------------------------------------------- */ - -template -Pair *Force::pair_creator(LAMMPS *lmp) -{ - return new T(lmp); -} - /* ---------------------------------------------------------------------- return ptr to Pair class if matches word or matches hybrid sub-style if exact, then style name must be exact match to word @@ -391,16 +414,6 @@ Bond *Force::new_bond(const std::string &style, int trysuffix, int &sflag) return nullptr; } -/* ---------------------------------------------------------------------- - one instance per bond style in style_bond.h -------------------------------------------------------------------------- */ - -template -Bond *Force::bond_creator(LAMMPS *lmp) -{ - return new T(lmp); -} - /* ---------------------------------------------------------------------- return ptr to current bond class or hybrid sub-class if matches style ------------------------------------------------------------------------- */ @@ -468,16 +481,6 @@ Angle *Force::new_angle(const std::string &style, int trysuffix, int &sflag) return nullptr; } -/* ---------------------------------------------------------------------- - one instance per angle style in style_angle.h -------------------------------------------------------------------------- */ - -template -Angle *Force::angle_creator(LAMMPS *lmp) -{ - return new T(lmp); -} - /* ---------------------------------------------------------------------- return ptr to current angle class or hybrid sub-class if matches style ------------------------------------------------------------------------- */ @@ -545,16 +548,6 @@ Dihedral *Force::new_dihedral(const std::string &style, int trysuffix, int &sfla return nullptr; } -/* ---------------------------------------------------------------------- - one instance per dihedral style in style_dihedral.h -------------------------------------------------------------------------- */ - -template -Dihedral *Force::dihedral_creator(LAMMPS *lmp) -{ - return new T(lmp); -} - /* ---------------------------------------------------------------------- return ptr to current angle class or hybrid sub-class if matches style ------------------------------------------------------------------------- */ @@ -622,16 +615,6 @@ Improper *Force::new_improper(const std::string &style, int trysuffix, int &sfla return nullptr; } -/* ---------------------------------------------------------------------- - one instance per improper style in style_improper.h -------------------------------------------------------------------------- */ - -template -Improper *Force::improper_creator(LAMMPS *lmp) -{ - return new T(lmp); -} - /* ---------------------------------------------------------------------- return ptr to current improper class or hybrid sub-class if matches style ------------------------------------------------------------------------- */ @@ -699,16 +682,6 @@ KSpace *Force::new_kspace(const std::string &style, int trysuffix, int &sflag) return nullptr; } -/* ---------------------------------------------------------------------- - one instance per kspace style in style_kspace.h -------------------------------------------------------------------------- */ - -template -KSpace *Force::kspace_creator(LAMMPS *lmp) -{ - return new T(lmp); -} - /* ---------------------------------------------------------------------- return ptr to Kspace class if matches word if exact, then style name must be exact match to word diff --git a/src/force.h b/src/force.h index 3ea03fdbe2..677817f4b3 100644 --- a/src/force.h +++ b/src/force.h @@ -153,12 +153,6 @@ class Force : protected Pointers { private: void create_factories(); - template static Pair *pair_creator(LAMMPS *); - template static Bond *bond_creator(LAMMPS *); - template static Angle *angle_creator(LAMMPS *); - template static Dihedral *dihedral_creator(LAMMPS *); - template static Improper *improper_creator(LAMMPS *); - template static KSpace *kspace_creator(LAMMPS *); }; } // namespace LAMMPS_NS diff --git a/src/modify.cpp b/src/modify.cpp index 2f7abe27fa..e3976f3622 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -37,6 +37,19 @@ 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 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) +{ + return new T(lmp,narg,arg); +} + /* ---------------------------------------------------------------------- */ Modify::Modify(LAMMPS *lmp) : Pointers(lmp) @@ -1024,16 +1037,6 @@ Fix *Modify::replace_fix(const std::string &oldfix, const std::string &fixcmd, i return replace_fix(oldfix.c_str(),args.size(),newarg.data(),trysuffix); } -/* ---------------------------------------------------------------------- - one instance per fix in style_fix.h -------------------------------------------------------------------------- */ - -template -Fix *Modify::fix_creator(LAMMPS *lmp, int narg, char **arg) -{ - return new T(lmp,narg,arg); -} - /* ---------------------------------------------------------------------- modify a Fix's parameters ------------------------------------------------------------------------- */ @@ -1310,17 +1313,6 @@ Compute *Modify::add_compute(const std::string &computecmd, int trysuffix) return add_compute(args.size(),newarg.data(),trysuffix); } - -/* ---------------------------------------------------------------------- - one instance per compute in style_compute.h -------------------------------------------------------------------------- */ - -template -Compute *Modify::compute_creator(LAMMPS *lmp, int narg, char **arg) -{ - return new T(lmp,narg,arg); -} - /* ---------------------------------------------------------------------- modify a Compute's parameters ------------------------------------------------------------------------- */ diff --git a/src/modify.h b/src/modify.h index e340012b04..df8e52752f 100644 --- a/src/modify.h +++ b/src/modify.h @@ -201,8 +201,6 @@ class Modify : protected Pointers { protected: void create_factories(); - template static Compute *compute_creator(LAMMPS *, int, char **); - template static Fix *fix_creator(LAMMPS *, int, char **); }; } // namespace LAMMPS_NS