new accessor APIs for fixes and computes in Modify plus a few applications

This commit is contained in:
Axel Kohlmeyer
2021-08-08 17:25:06 -04:00
parent ef04f6ca69
commit 5b40e4cb38
20 changed files with 397 additions and 388 deletions

View File

@ -1103,6 +1103,45 @@ int Modify::find_fix_by_style(const char *style)
return -1;
}
/* ----------------------------------------------------------------------
look up pointer to Fix class by fix-ID
return null pointer if ID not found
------------------------------------------------------------------------- */
Fix *Modify::get_fix_by_id(const std::string &id) const
{
if (id.empty()) return nullptr;
for (int ifix = 0; ifix < nfix; ifix++)
if (id == fix[ifix]->id) return fix[ifix];
return nullptr;
}
/* ----------------------------------------------------------------------
look up pointer to fixes by fix style name
return vector of matching pointers
------------------------------------------------------------------------- */
const std::vector<Fix *> Modify::get_fix_by_style(const std::string &style) const
{
std::vector<Fix *> matches;
if (style.empty()) return matches;
for (int ifix = 0; ifix < nfix; ifix++)
if (utils::strmatch(fix[ifix]->style,style)) matches.push_back(fix[ifix]);
return matches;
}
/* ----------------------------------------------------------------------
return list of fixes as vector
------------------------------------------------------------------------- */
const std::vector<Fix *> &Modify::get_fix_list()
{
fix_list = std::vector<Fix *>(fix, fix+nfix);
return fix_list;
}
/* ----------------------------------------------------------------------
check for fix associated with package name in compiled list
return 1 if found else 0
@ -1359,6 +1398,45 @@ int Modify::find_compute_by_style(const char *style)
return -1;
}
/* ----------------------------------------------------------------------
look up pointer to Compute class by compute-ID
return null pointer if ID not found
------------------------------------------------------------------------- */
Compute *Modify::get_compute_by_id(const std::string &id) const
{
if (id.empty()) return nullptr;
for (int icompute = 0; icompute < ncompute; icompute++)
if (id == compute[icompute]->id) return compute[icompute];
return nullptr;
}
/* ----------------------------------------------------------------------
look up pointer to compute by compute style name
return null pointer if style not used
------------------------------------------------------------------------- */
const std::vector<Compute *> Modify::get_compute_by_style(const std::string &style) const
{
std::vector<Compute *> matches;
if (style.empty()) return matches;
for (int icompute = 0; icompute < ncompute; icompute++)
if (utils::strmatch(compute[icompute]->style,style)) matches.push_back(compute[icompute]);
return matches;
}
/* ----------------------------------------------------------------------
return vector with Computes
------------------------------------------------------------------------- */
const std::vector<Compute *> &Modify::get_compute_list()
{
compute_list = std::vector<Compute *>(compute, compute+ncompute);
return compute_list;
}
/* ----------------------------------------------------------------------
clear invoked flag of all computes
called everywhere that computes are used, before computes are invoked