Unverified Commit da66516d authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

use references when creating styles

parent 3847a300
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -653,7 +653,7 @@ AtomVec *Atom::new_avec(const std::string &style, int trysuffix, int &sflag)
      sflag = 1;
      std::string estyle = style + "/" + lmp->suffix;
      if (avec_map->find(estyle) != avec_map->end()) {
        AtomVecCreator avec_creator = (*avec_map)[estyle];
        AtomVecCreator &avec_creator = (*avec_map)[estyle];
        return avec_creator(lmp);
      }
    }
@@ -662,7 +662,7 @@ AtomVec *Atom::new_avec(const std::string &style, int trysuffix, int &sflag)
      sflag = 2;
      std::string estyle = style + "/" + lmp->suffix2;
      if (avec_map->find(estyle) != avec_map->end()) {
        AtomVecCreator avec_creator = (*avec_map)[estyle];
        AtomVecCreator &avec_creator = (*avec_map)[estyle];
        return avec_creator(lmp);
      }
    }
@@ -670,7 +670,7 @@ AtomVec *Atom::new_avec(const std::string &style, int trysuffix, int &sflag)

  sflag = 0;
  if (avec_map->find(style) != avec_map->end()) {
    AtomVecCreator avec_creator = (*avec_map)[style];
    AtomVecCreator &avec_creator = (*avec_map)[style];
    return avec_creator(lmp);
  }

+3 −3
Original line number Diff line number Diff line
@@ -1764,7 +1764,7 @@ void Domain::add_region(int narg, char **arg)
    if (lmp->suffix) {
      std::string estyle = std::string(arg[1]) + "/" + lmp->suffix;
      if (region_map->find(estyle) != region_map->end()) {
        RegionCreator region_creator = (*region_map)[estyle];
        RegionCreator &region_creator = (*region_map)[estyle];
        regions[nregion] = region_creator(lmp, narg, arg);
        regions[nregion]->init();
        nregion++;
@@ -1775,7 +1775,7 @@ void Domain::add_region(int narg, char **arg)
    if (lmp->suffix2) {
      std::string estyle = std::string(arg[1]) + "/" + lmp->suffix2;
      if (region_map->find(estyle) != region_map->end()) {
        RegionCreator region_creator = (*region_map)[estyle];
        RegionCreator &region_creator = (*region_map)[estyle];
        regions[nregion] = region_creator(lmp, narg, arg);
        regions[nregion]->init();
        nregion++;
@@ -1785,7 +1785,7 @@ void Domain::add_region(int narg, char **arg)
  }

  if (region_map->find(arg[1]) != region_map->end()) {
    RegionCreator region_creator = (*region_map)[arg[1]];
    RegionCreator &region_creator = (*region_map)[arg[1]];
    regions[nregion] = region_creator(lmp, narg, arg);
  } else error->all(FLERR,utils::check_packages_for_style("region",arg[1],lmp));

+18 −18
Original line number Diff line number Diff line
@@ -259,7 +259,7 @@ Pair *Force::new_pair(const std::string &style, int trysuffix, int &sflag)
      sflag = 1;
      std::string estyle = style + "/" + lmp->suffix;
      if (pair_map->find(estyle) != pair_map->end()) {
        PairCreator pair_creator = (*pair_map)[estyle];
        PairCreator &pair_creator = (*pair_map)[estyle];
        return pair_creator(lmp);
      }
    }
@@ -267,7 +267,7 @@ Pair *Force::new_pair(const std::string &style, int trysuffix, int &sflag)
      sflag = 2;
      std::string estyle = style + "/" + lmp->suffix2;
      if (pair_map->find(estyle) != pair_map->end()) {
        PairCreator pair_creator = (*pair_map)[estyle];
        PairCreator &pair_creator = (*pair_map)[estyle];
        return pair_creator(lmp);
      }
    }
@@ -276,7 +276,7 @@ Pair *Force::new_pair(const std::string &style, int trysuffix, int &sflag)
  sflag = 0;
  if (style == "none") return NULL;
  if (pair_map->find(style) != pair_map->end()) {
    PairCreator pair_creator = (*pair_map)[style];
    PairCreator &pair_creator = (*pair_map)[style];
    return pair_creator(lmp);
  }

@@ -369,7 +369,7 @@ Bond *Force::new_bond(const std::string &style, int trysuffix, int &sflag)
      sflag = 1;
      std::string estyle = style + "/" + lmp->suffix;
      if (bond_map->find(estyle) != bond_map->end()) {
        BondCreator bond_creator = (*bond_map)[estyle];
        BondCreator &bond_creator = (*bond_map)[estyle];
        return bond_creator(lmp);
      }
    }
@@ -378,7 +378,7 @@ Bond *Force::new_bond(const std::string &style, int trysuffix, int &sflag)
      sflag = 2;
      std::string estyle = style + "/" + lmp->suffix2;
      if (bond_map->find(estyle) != bond_map->end()) {
        BondCreator bond_creator = (*bond_map)[estyle];
        BondCreator &bond_creator = (*bond_map)[estyle];
        return bond_creator(lmp);
      }
    }
@@ -387,7 +387,7 @@ Bond *Force::new_bond(const std::string &style, int trysuffix, int &sflag)
  sflag = 0;
  if (style == "none") return NULL;
  if (bond_map->find(style) != bond_map->end()) {
    BondCreator bond_creator = (*bond_map)[style];
    BondCreator &bond_creator = (*bond_map)[style];
    return bond_creator(lmp);
  }

@@ -446,7 +446,7 @@ Angle *Force::new_angle(const std::string &style, int trysuffix, int &sflag)
      sflag = 1;
      std::string estyle = style + "/" + lmp->suffix;
      if (angle_map->find(estyle) != angle_map->end()) {
        AngleCreator angle_creator = (*angle_map)[estyle];
        AngleCreator &angle_creator = (*angle_map)[estyle];
        return angle_creator(lmp);
      }
    }
@@ -455,7 +455,7 @@ Angle *Force::new_angle(const std::string &style, int trysuffix, int &sflag)
      sflag = 2;
      std::string estyle = style + "/" + lmp->suffix;
      if (angle_map->find(estyle) != angle_map->end()) {
        AngleCreator angle_creator = (*angle_map)[estyle];
        AngleCreator &angle_creator = (*angle_map)[estyle];
        return angle_creator(lmp);
      }
    }
@@ -464,7 +464,7 @@ Angle *Force::new_angle(const std::string &style, int trysuffix, int &sflag)
  sflag = 0;
  if (style == "none") return NULL;
  if (angle_map->find(style) != angle_map->end()) {
    AngleCreator angle_creator = (*angle_map)[style];
    AngleCreator &angle_creator = (*angle_map)[style];
    return angle_creator(lmp);
  }

@@ -523,7 +523,7 @@ Dihedral *Force::new_dihedral(const std::string &style, int trysuffix, int &sfla
      sflag = 1;
      std::string estyle = style + "/" + lmp->suffix;
      if (dihedral_map->find(estyle) != dihedral_map->end()) {
        DihedralCreator dihedral_creator = (*dihedral_map)[estyle];
        DihedralCreator &dihedral_creator = (*dihedral_map)[estyle];
        return dihedral_creator(lmp);
      }
    }
@@ -532,7 +532,7 @@ Dihedral *Force::new_dihedral(const std::string &style, int trysuffix, int &sfla
      sflag = 2;
      std::string estyle = style + "/" + lmp->suffix2;
      if (dihedral_map->find(estyle) != dihedral_map->end()) {
        DihedralCreator dihedral_creator = (*dihedral_map)[estyle];
        DihedralCreator &dihedral_creator = (*dihedral_map)[estyle];
        return dihedral_creator(lmp);
      }
    }
@@ -541,7 +541,7 @@ Dihedral *Force::new_dihedral(const std::string &style, int trysuffix, int &sfla
  sflag = 0;
  if (style == "none") return NULL;
  if (dihedral_map->find(style) != dihedral_map->end()) {
    DihedralCreator dihedral_creator = (*dihedral_map)[style];
    DihedralCreator &dihedral_creator = (*dihedral_map)[style];
    return dihedral_creator(lmp);
  }

@@ -600,7 +600,7 @@ Improper *Force::new_improper(const std::string &style, int trysuffix, int &sfla
      sflag = 1;
      std::string estyle = style + "/" + lmp->suffix;
      if (improper_map->find(estyle) != improper_map->end()) {
        ImproperCreator improper_creator = (*improper_map)[estyle];
        ImproperCreator &improper_creator = (*improper_map)[estyle];
        return improper_creator(lmp);
      }
    }
@@ -609,7 +609,7 @@ Improper *Force::new_improper(const std::string &style, int trysuffix, int &sfla
      sflag = 2;
      std::string estyle = style + "/" + lmp->suffix2;
      if (improper_map->find(estyle) != improper_map->end()) {
        ImproperCreator improper_creator = (*improper_map)[estyle];
        ImproperCreator &improper_creator = (*improper_map)[estyle];
        return improper_creator(lmp);
      }
    }
@@ -618,7 +618,7 @@ Improper *Force::new_improper(const std::string &style, int trysuffix, int &sfla
  sflag = 0;
  if (style == "none") return NULL;
  if (improper_map->find(style) != improper_map->end()) {
    ImproperCreator improper_creator = (*improper_map)[style];
    ImproperCreator &improper_creator = (*improper_map)[style];
    return improper_creator(lmp);
  }

@@ -681,7 +681,7 @@ KSpace *Force::new_kspace(const std::string &style, int trysuffix, int &sflag)
      sflag = 1;
      std::string estyle = style + "/" + lmp->suffix;
      if (kspace_map->find(estyle) != kspace_map->end()) {
        KSpaceCreator kspace_creator = (*kspace_map)[estyle];
        KSpaceCreator &kspace_creator = (*kspace_map)[estyle];
        return kspace_creator(lmp);
      }
    }
@@ -690,7 +690,7 @@ KSpace *Force::new_kspace(const std::string &style, int trysuffix, int &sflag)
      sflag = 1;
      std::string estyle = style + "/" + lmp->suffix2;
      if (kspace_map->find(estyle) != kspace_map->end()) {
        KSpaceCreator kspace_creator = (*kspace_map)[estyle];
        KSpaceCreator &kspace_creator = (*kspace_map)[estyle];
        return kspace_creator(lmp);
      }
    }
@@ -699,7 +699,7 @@ KSpace *Force::new_kspace(const std::string &style, int trysuffix, int &sflag)
  sflag = 0;
  if (style == "none") return NULL;
  if (kspace_map->find(style) != kspace_map->end()) {
    KSpaceCreator kspace_creator = (*kspace_map)[style];
    KSpaceCreator &kspace_creator = (*kspace_map)[style];
    return kspace_creator(lmp);
  }

+1 −1
Original line number Diff line number Diff line
@@ -853,7 +853,7 @@ int Input::execute_command()
  // invoke commands added via style_command.h

  if (command_map->find(command) != command_map->end()) {
    CommandCreator command_creator = (*command_map)[command];
    CommandCreator &command_creator = (*command_map)[command];
    command_creator(lmp,narg,arg);
    return 0;
  }
+6 −6
Original line number Diff line number Diff line
@@ -872,7 +872,7 @@ void Modify::add_fix(int narg, char **arg, int trysuffix)
    if (lmp->suffix) {
      std::string estyle = arg[2] + std::string("/") + lmp->suffix;
      if (fix_map->find(estyle) != fix_map->end()) {
        FixCreator fix_creator = (*fix_map)[estyle];
        FixCreator &fix_creator = (*fix_map)[estyle];
        fix[ifix] = fix_creator(lmp,narg,arg);
        delete[] fix[ifix]->style;
        fix[ifix]->style = new char[estyle.size()+1];
@@ -882,7 +882,7 @@ void Modify::add_fix(int narg, char **arg, int trysuffix)
    if (fix[ifix] == NULL && lmp->suffix2) {
      std::string estyle = arg[2] + std::string("/") + lmp->suffix2;
      if (fix_map->find(estyle) != fix_map->end()) {
        FixCreator fix_creator = (*fix_map)[estyle];
        FixCreator &fix_creator = (*fix_map)[estyle];
        fix[ifix] = fix_creator(lmp,narg,arg);
        delete[] fix[ifix]->style;
        fix[ifix]->style = new char[estyle.size()+1];
@@ -892,7 +892,7 @@ void Modify::add_fix(int narg, char **arg, int trysuffix)
  }

  if (fix[ifix] == NULL && fix_map->find(arg[2]) != fix_map->end()) {
    FixCreator fix_creator = (*fix_map)[arg[2]];
    FixCreator &fix_creator = (*fix_map)[arg[2]];
    fix[ifix] = fix_creator(lmp,narg,arg);
  }

@@ -1212,7 +1212,7 @@ void Modify::add_compute(int narg, char **arg, int trysuffix)
    if (lmp->suffix) {
      std::string estyle = arg[2] + std::string("/") + lmp->suffix;
      if (compute_map->find(estyle) != compute_map->end()) {
        ComputeCreator compute_creator = (*compute_map)[estyle];
        ComputeCreator &compute_creator = (*compute_map)[estyle];
        compute[ncompute] = compute_creator(lmp,narg,arg);
        delete[] compute[ncompute]->style;
        compute[ncompute]->style = new char[estyle.size()+1];
@@ -1222,7 +1222,7 @@ void Modify::add_compute(int narg, char **arg, int trysuffix)
    if (compute[ncompute] == NULL && lmp->suffix2) {
      std::string estyle = arg[2] + std::string("/") + lmp->suffix2;
      if (compute_map->find(estyle) != compute_map->end()) {
        ComputeCreator compute_creator = (*compute_map)[estyle];
        ComputeCreator &compute_creator = (*compute_map)[estyle];
        compute[ncompute] = compute_creator(lmp,narg,arg);
        delete[] compute[ncompute]->style;
        compute[ncompute]->style = new char[estyle.size()+1];
@@ -1233,7 +1233,7 @@ void Modify::add_compute(int narg, char **arg, int trysuffix)

  if (compute[ncompute] == NULL &&
      compute_map->find(arg[2]) != compute_map->end()) {
    ComputeCreator compute_creator = (*compute_map)[arg[2]];
    ComputeCreator &compute_creator = (*compute_map)[arg[2]];
    compute[ncompute] = compute_creator(lmp,narg,arg);
  }

Loading