Options _options;
std::string _fnDist;
double _cutoff;
- Selection *_refsel;
- std::vector<Selection *> _sel;
+ Selection _refsel;
+ SelectionList _sel;
AnalysisData _data;
AnalysisDataAverageModulePointer _avem;
};
AnalysisTemplate::AnalysisTemplate()
: _options("template", "Template options"), _cutoff(0.0),
- _refsel(NULL), _avem(new AnalysisDataAverageModule())
+ _avem(new AnalysisDataAverageModule())
{
}
const SelectionCollection &selections)
{
return TrajectoryAnalysisModuleDataPointer(
- new ModuleData(this, opt, selections, _cutoff, _refsel->posCount()));
+ new ModuleData(this, opt, selections, _cutoff, _refsel.posCount()));
}
{
AnalysisDataHandle dh = pdata->dataHandle(_data);
NeighborhoodSearch &nb = static_cast<ModuleData *>(pdata)->_nb;
- Selection *refsel = pdata->parallelSelection(_refsel);
+ const Selection &refsel = pdata->parallelSelection(_refsel);
- nb.init(pbc, refsel->positions());
+ nb.init(pbc, refsel.positions());
dh.startFrame(frnr, fr.time);
for (size_t g = 0; g < _sel.size(); ++g)
{
- Selection *sel = pdata->parallelSelection(_sel[g]);
- int nr = sel->posCount();
+ const Selection &sel = pdata->parallelSelection(_sel[g]);
+ int nr = sel.posCount();
real frave = 0.0;
for (int i = 0; i < nr; ++i)
{
- SelectionPosition p = sel->position(i);
+ SelectionPosition p = sel.position(i);
frave += nb.minimumDistance(p.x());
}
frave /= nr;
for (size_t g = 0; g < _sel.size(); ++g)
{
fprintf(stderr, "Average mean distance for '%s': %.3f nm\n",
- _sel[g]->name(), _avem->average(g));
+ _sel[g].name(), _avem->average(g));
}
}
* for, or NULL if the element is an internal element.
*/
static void
-init_pos_keyword_defaults(t_selelem *root, const char *spost,
- const char *rpost, const gmx::Selection *sel)
+init_pos_keyword_defaults(t_selelem *root, const char *spost, const char *rpost,
+ const gmx::internal::SelectionData *sel)
{
/* Selections use largest static group by default, while
* reference positions use the whole residue/molecule. */
*/
for (i = 0; i < sc->sel.size(); ++i)
{
- gmx::Selection *sel = sc->sel[i].get();
- init_pos_keyword_defaults(sel->rootElement_,
+ gmx::internal::SelectionData &sel = *sc->sel[i];
+ init_pos_keyword_defaults(sel.rootElement(),
coll->_impl->_spost.c_str(),
coll->_impl->_rpost.c_str(),
- sel);
+ &sel);
}
/* Remove any unused variables. */
sel = sel->next;
}
/* Update selection information */
- SelectionList::const_iterator isel;
+ SelectionDataList::const_iterator isel;
for (isel = sc->sel.begin(); isel != sc->sel.end(); ++isel)
{
- Selection &sel = **isel;
+ internal::SelectionData &sel = **isel;
sel.refreshMassesAndCharges();
sel.updateCoveredFractionForFrame();
}
{
gmx_ana_selcollection_t *sc = &coll->_impl->_sc;
- SelectionList::const_iterator isel;
+ SelectionDataList::const_iterator isel;
for (isel = sc->sel.begin(); isel != sc->sel.end(); ++isel)
{
- Selection &sel = **isel;
+ internal::SelectionData &sel = **isel;
sel.restoreOriginalPositions();
sel.computeAverageCoveredFraction(nframes);
}
/* Add the new selection to the collection if it is not a variable. */
if (sel->child->type != SEL_SUBEXPR)
{
- gmx::SelectionPointer selPtr(
- new gmx::Selection(sel, _gmx_sel_lexer_pselstr(scanner)));
- sc->sel.push_back(move(selPtr));
+ gmx::SelectionDataPointer selPtr(
+ new gmx::internal::SelectionData(
+ sel, _gmx_sel_lexer_pselstr(scanner)));
+ sc->sel.push_back(gmx::move(selPtr));
}
}
/* Clear the selection string now that we've saved it */
namespace gmx
{
-Selection::Selection(t_selelem *elem, const char *selstr)
+namespace internal
+{
+
+SelectionData::SelectionData(t_selelem *elem, const char *selstr)
: name_(elem->name), selectionText_(selstr),
rootElement_(elem), coveredFractionType_(CFRAC_NONE),
coveredFraction_(1.0), averageCoveredFraction_(1.0),
}
-Selection::~Selection()
+SelectionData::~SelectionData()
{
gmx_ana_pos_deinit(&rawPositions_);
}
-void
-Selection::printInfo(FILE *fp) const
-{
- fprintf(fp, "\"%s\" (%d position%s, %d atom%s%s)", name_.c_str(),
- posCount(), posCount() == 1 ? "" : "s",
- atomCount(), atomCount() == 1 ? "" : "s",
- isDynamic() ? ", dynamic" : "");
- fprintf(fp, "\n");
-}
-
-
bool
-Selection::initCoveredFraction(e_coverfrac_t type)
+SelectionData::initCoveredFraction(e_coverfrac_t type)
{
coveredFractionType_ = type;
if (type == CFRAC_NONE || rootElement_ == NULL)
void
-Selection::printDebugInfo(FILE *fp, int nmaxind) const
-{
- const gmx_ana_pos_t &p = rawPositions_;
-
- fprintf(fp, " ");
- printInfo(fp);
- fprintf(fp, " ");
- gmx_ana_index_dump(fp, p.g, -1, nmaxind);
-
- fprintf(fp, " Block (size=%d):", p.m.mapb.nr);
- if (!p.m.mapb.index)
- {
- fprintf(fp, " (null)");
- }
- else
- {
- int n = p.m.mapb.nr;
- if (nmaxind >= 0 && n > nmaxind)
- n = nmaxind;
- for (int i = 0; i <= n; ++i)
- fprintf(fp, " %d", p.m.mapb.index[i]);
- if (n < p.m.mapb.nr)
- fprintf(fp, " ...");
- }
- fprintf(fp, "\n");
-
- int n = posCount();
- if (nmaxind >= 0 && n > nmaxind)
- n = nmaxind;
- fprintf(fp, " RefId:");
- if (!p.m.refid)
- {
- fprintf(fp, " (null)");
- }
- else
- {
- for (int i = 0; i < n; ++i)
- fprintf(fp, " %d", p.m.refid[i]);
- if (n < posCount())
- fprintf(fp, " ...");
- }
- fprintf(fp, "\n");
-
- fprintf(fp, " MapId:");
- if (!p.m.mapid)
- {
- fprintf(fp, " (null)");
- }
- else
- {
- for (int i = 0; i < n; ++i)
- fprintf(fp, " %d", p.m.mapid[i]);
- if (n < posCount())
- fprintf(fp, " ...");
- }
- fprintf(fp, "\n");
-}
-
-
-void
-Selection::initializeMassesAndCharges(const t_topology *top)
+SelectionData::initializeMassesAndCharges(const t_topology *top)
{
posInfo_.reserve(posCount());
for (int b = 0; b < posCount(); ++b)
void
-Selection::refreshMassesAndCharges()
+SelectionData::refreshMassesAndCharges()
{
if (!originalPosInfo_.empty())
{
void
-Selection::updateCoveredFractionForFrame()
+SelectionData::updateCoveredFractionForFrame()
{
if (isCoveredFractionDynamic())
{
- real cfrac = _gmx_selelem_estimate_coverfrac(rootElement_);
+ real cfrac = _gmx_selelem_estimate_coverfrac(rootElement());
coveredFraction_ = cfrac;
averageCoveredFraction_ += cfrac;
}
void
-Selection::computeAverageCoveredFraction(int nframes)
+SelectionData::computeAverageCoveredFraction(int nframes)
{
if (isCoveredFractionDynamic() && nframes > 0)
{
void
-Selection::restoreOriginalPositions()
+SelectionData::restoreOriginalPositions()
{
if (isDynamic())
{
}
}
+} // namespace internal
+
+
+void
+Selection::printInfo(FILE *fp) const
+{
+ fprintf(fp, "\"%s\" (%d position%s, %d atom%s%s)", name(),
+ posCount(), posCount() == 1 ? "" : "s",
+ atomCount(), atomCount() == 1 ? "" : "s",
+ isDynamic() ? ", dynamic" : "");
+ fprintf(fp, "\n");
+}
+
+
+void
+Selection::printDebugInfo(FILE *fp, int nmaxind) const
+{
+ const gmx_ana_pos_t &p = sel_->rawPositions_;
+
+ fprintf(fp, " ");
+ printInfo(fp);
+ fprintf(fp, " ");
+ gmx_ana_index_dump(fp, p.g, -1, nmaxind);
+
+ fprintf(fp, " Block (size=%d):", p.m.mapb.nr);
+ if (!p.m.mapb.index)
+ {
+ fprintf(fp, " (null)");
+ }
+ else
+ {
+ int n = p.m.mapb.nr;
+ if (nmaxind >= 0 && n > nmaxind)
+ n = nmaxind;
+ for (int i = 0; i <= n; ++i)
+ fprintf(fp, " %d", p.m.mapb.index[i]);
+ if (n < p.m.mapb.nr)
+ fprintf(fp, " ...");
+ }
+ fprintf(fp, "\n");
+
+ int n = posCount();
+ if (nmaxind >= 0 && n > nmaxind)
+ n = nmaxind;
+ fprintf(fp, " RefId:");
+ if (!p.m.refid)
+ {
+ fprintf(fp, " (null)");
+ }
+ else
+ {
+ for (int i = 0; i < n; ++i)
+ fprintf(fp, " %d", p.m.refid[i]);
+ if (n < posCount())
+ fprintf(fp, " ...");
+ }
+ fprintf(fp, "\n");
+
+ fprintf(fp, " MapId:");
+ if (!p.m.mapid)
+ {
+ fprintf(fp, " (null)");
+ }
+ else
+ {
+ for (int i = 0; i < n; ++i)
+ fprintf(fp, " %d", p.m.mapid[i]);
+ if (n < posCount())
+ fprintf(fp, " ...");
+ }
+ fprintf(fp, "\n");
+}
+
} // namespace gmx
namespace gmx
{
-class SelectionEvaluator;
-class SelectionCollection;
-class SelectionCompiler;
+class SelectionOptionStorage;
+class Selection;
class SelectionPosition;
-/*! \brief
- * Provides access to a single selection.
+//! Container of selections used in public selection interfaces.
+typedef std::vector<Selection> SelectionList;
+
+namespace internal
+{
+
+/*! \internal \brief
+ * Internal data for a single selection.
+ *
+ * This class is internal to the selection module, but resides in a public
+ * header because of efficiency reasons: it allows frequently used access
+ * methods to be inlined.
*
- * \inpublicapi
* \ingroup module_selection
*/
-class Selection
+class SelectionData
{
public:
/*! \brief
* \param[in] elem Root of the evaluation tree for this selection.
* \param[in] selstr String that was parsed to produce this selection.
*/
- Selection(t_selelem *elem, const char *selstr);
- ~Selection();
+ SelectionData(t_selelem *elem, const char *selstr);
+ ~SelectionData();
- //! Returns the name of the selection.
- const char *name() const { return name_.c_str(); }
//! Returns the string that was parsed to produce this selection.
const char *selectionText() const { return selectionText_.c_str(); }
//! Returns true if the size of the selection (posCount()) is dynamic.
bool isDynamic() const { return bDynamic_; }
- //! Returns the type of positions in the selection.
- e_index_t type() const { return rawPositions_.m.type; }
-
//! Number of positions in the selection.
int posCount() const { return rawPositions_.nr; }
- //! Total number of atoms in the selection.
- int atomCount() const
- {
- return rawPositions_.g != NULL ? rawPositions_.g->isize : 0;
- }
- //! Returns atom indices of all atoms in the selection.
- ConstArrayRef<int> atomIndices() const
- {
- if (rawPositions_.g == NULL)
- {
- return ConstArrayRef<int>();
- }
- return ConstArrayRef<int>(rawPositions_.g->isize,
- rawPositions_.g->index);
- }
- //! Access a single position.
- SelectionPosition position(int i) const;
- /*! \brief
- * Sets the ID for the \p i'th position for use with
- * SelectionPosition::mappedId().
- *
- * This method is not part of SelectionPosition because that interface
- * only provides access to const data by design.
- */
- void setOriginalId(int i, int id) { rawPositions_.m.orgid[i] = id; }
+ //! Returns the root of the evaluation tree for this selection.
+ t_selelem *rootElement() { return rootElement_; }
//! Returns whether the covered fraction can change between frames.
bool isCoveredFractionDynamic() const { return bDynamicCoveredFraction_; }
- //! Returns the covered fraction for the current frame.
- real coveredFraction() const { return coveredFraction_; }
-
- //! Deprecated method for direct access to position data.
- const gmx_ana_pos_t *positions() const { return &rawPositions_; }
- //! Deprecated method for direct access to atom index data.
- gmx_ana_index_t *indexGroup() const { return rawPositions_.g; }
- // TODO: Remove direct access to the flags from the public interface.
//! Returns true if the given flag is set.
bool hasFlag(SelectionFlag flag) const { return flags_.test(flag); }
//! Sets the flags for this selection.
void setFlags(SelectionFlags flags) { flags_ = flags; }
- /*! \brief
- * Initializes information about covered fractions.
- *
- * \param[in] type Type of covered fraction required.
- * \returns True if the covered fraction can be calculated for the
- * selection.
- */
- bool initCoveredFraction(e_coverfrac_t type);
-
- /*! \brief
- * Prints out one-line description of the selection.
- *
- * \param[in] fp Where to print the information.
- */
- void printInfo(FILE *fp) const;
- /*! \brief
- * Prints out extended information about the selection for debugging.
- *
- * \param[in] fp Where to print the information.
- * \param[in] nmaxind Maximum number of values to print in lists
- * (-1 = print all).
- */
- void printDebugInfo(FILE *fp, int nmaxind) const;
-
- private:
- /*! \brief
- * Additional information about positions.
- *
- * This structure contains information about positions in the
- * selection that is not stored in ::gmx_ana_pos_t.
- */
- struct PositionInfo
- {
- //! Construct position information with unit mass and no charge.
- PositionInfo() : mass(1.0), charge(0.0) {}
- //! Construct position information with the given information.
- PositionInfo(real mass, real charge) : mass(mass), charge(charge) {}
- //! Total mass of atoms that make up the position.
- real mass;
- //! Total charge of atoms that make up the position.
- real charge;
- };
+ //! \copydoc Selection::initCoveredFraction()
+ bool initCoveredFraction(e_coverfrac_t type);
/*! \brief
* Computes total masses and charges for all selection positions.
*/
void restoreOriginalPositions();
+ private:
+ /*! \brief
+ * Additional information about positions.
+ *
+ * This structure contains information about positions in the
+ * selection that is not stored in ::gmx_ana_pos_t.
+ */
+ struct PositionInfo
+ {
+ //! Construct position information with unit mass and no charge.
+ PositionInfo() : mass(1.0), charge(0.0) {}
+ //! Construct position information with the given information.
+ PositionInfo(real mass, real charge) : mass(mass), charge(charge) {}
+
+ //! Total mass of atoms that make up the position.
+ real mass;
+ //! Total charge of atoms that make up the position.
+ real charge;
+ };
+
//! Name of the selection.
std::string name_;
//! The actual selection string.
bool bDynamicCoveredFraction_;
/*! \brief
- * Needed for the compiler to access initializeMassesAndCharges().
+ * Needed for to wrap access to information.
+ */
+ friend class gmx::Selection;
+ /*! \brief
+ * Needed for proper access to position information.
+ */
+ friend class gmx::SelectionPosition;
+
+ GMX_DISALLOW_COPY_AND_ASSIGN(SelectionData);
+};
+
+} // namespace internal
+
+/*! \brief
+ * Provides access to a single selection.
+ *
+ * \inpublicapi
+ * \ingroup module_selection
+ */
+class Selection
+{
+ public:
+ /*! \brief
+ * Creates a selection wrapper that has no associated selection.
+ *
+ * Any attempt to call methods in the object before a selection is
+ * assigned results in undefined behavior.
+ */
+ Selection() : sel_(NULL) {}
+ /*! \brief
+ * Creates a new selection object.
+ *
+ * \param sel Selection data to wrap.
+ */
+ explicit Selection(internal::SelectionData *sel) : sel_(sel) {}
+
+ //! Returns the name of the selection.
+ const char *name() const { return data().name_.c_str(); }
+ //! Returns the string that was parsed to produce this selection.
+ const char *selectionText() const { return data().selectionText(); }
+ //! Returns true if the size of the selection (posCount()) is dynamic.
+ bool isDynamic() const { return data().isDynamic(); }
+ //! Returns the type of positions in the selection.
+ e_index_t type() const { return data().rawPositions_.m.type; }
+
+ //! Number of positions in the selection.
+ int posCount() const { return data().posCount(); }
+ //! Total number of atoms in the selection.
+ int atomCount() const
+ {
+ return data().rawPositions_.g != NULL ? data().rawPositions_.g->isize : 0;
+ }
+ //! Returns atom indices of all atoms in the selection.
+ ConstArrayRef<int> atomIndices() const
+ {
+ if (data().rawPositions_.g == NULL)
+ {
+ return ConstArrayRef<int>();
+ }
+ return ConstArrayRef<int>(data().rawPositions_.g->isize,
+ data().rawPositions_.g->index);
+ }
+ //! Access a single position.
+ SelectionPosition position(int i) const;
+ /*! \brief
+ * Sets the ID for the \p i'th position for use with
+ * SelectionPosition::mappedId().
+ *
+ * This method is not part of SelectionPosition because that interface
+ * only provides access to const data by design.
+ */
+ void setOriginalId(int i, int id) { data().rawPositions_.m.orgid[i] = id; }
+
+ //! Returns whether the covered fraction can change between frames.
+ bool isCoveredFractionDynamic() const { return data().isCoveredFractionDynamic(); }
+ //! Returns the covered fraction for the current frame.
+ real coveredFraction() const { return data().coveredFraction_; }
+
+ //! Deprecated method for direct access to position data.
+ const gmx_ana_pos_t *positions() const { return &data().rawPositions_; }
+ //! Deprecated method for direct access to atom index data.
+ gmx_ana_index_t *indexGroup() const { return data().rawPositions_.g; }
+
+ /*! \brief
+ * Initializes information about covered fractions.
*
- * Currently the compiler also used rootElement_ directly for
- * simplicity, but does not modify it.
+ * \param[in] type Type of covered fraction required.
+ * \returns True if the covered fraction can be calculated for the
+ * selection.
*/
- friend class SelectionCompiler;
+ bool initCoveredFraction(e_coverfrac_t type)
+ {
+ return data().initCoveredFraction(type);
+ }
+
/*! \brief
- * Needed for the evaluator to access the private methods.
+ * Prints out one-line description of the selection.
+ *
+ * \param[in] fp Where to print the information.
*/
- friend class SelectionEvaluator;
+ void printInfo(FILE *fp) const;
/*! \brief
- * Needed for proper access to position information.
+ * Prints out extended information about the selection for debugging.
+ *
+ * \param[in] fp Where to print the information.
+ * \param[in] nmaxind Maximum number of values to print in lists
+ * (-1 = print all).
*/
- friend class SelectionPosition;
+ void printDebugInfo(FILE *fp, int nmaxind) const;
- GMX_DISALLOW_COPY_AND_ASSIGN(Selection);
+ private:
+ internal::SelectionData &data()
+ {
+ GMX_ASSERT(sel_ != NULL,
+ "Attempted to access uninitialized selection");
+ return *sel_;
+ }
+ const internal::SelectionData &data() const
+ {
+ GMX_ASSERT(sel_ != NULL,
+ "Attempted to access uninitialized selection");
+ return *sel_;
+ }
+
+ internal::SelectionData *sel_;
+
+ /*! \brief
+ * Needed to access the data to adjust flags.
+ */
+ friend class SelectionOptionStorage;
};
/*! \brief
*
* Does not throw. Asserts if \p index is out of range.
*/
- SelectionPosition(const Selection *sel, int index)
- : sel_(sel), i_(index)
+ SelectionPosition(const internal::SelectionData &sel, int index)
+ : sel_(&sel), i_(index)
{
- GMX_ASSERT(index >= 0 && index < sel->posCount(),
+ GMX_ASSERT(index >= 0 && index < sel.posCount(),
"Invalid selection position index");
}
}
private:
- const Selection *sel_;
- int i_;
+ const internal::SelectionData *sel_;
+ int i_;
};
inline SelectionPosition
Selection::position(int i) const
{
- return SelectionPosition(this, i);
+ return SelectionPosition(data(), i);
}
} // namespace gmx
#include "../utility/flags.h"
#include "../utility/uniqueptr.h"
#include "indexutil.h"
+#include "selection.h" // For gmx::SelectionList
#include "selectioncollection.h"
namespace gmx
{
-class Selection;
-
-//! Smart pointer for managing a selection.
-typedef gmx_unique_ptr<Selection>::type SelectionPointer;
+//! Smart pointer for managing an internal selection data object.
+typedef gmx_unique_ptr<internal::SelectionData>::type SelectionDataPointer;
//! Shorthand for storing a list of selections internally.
-typedef std::vector<SelectionPointer> SelectionList;
+typedef std::vector<SelectionDataPointer> SelectionDataList;
}
/*! \internal \brief
{
/** Root of the selection element tree. */
struct t_selelem *root;
- /** Array of compiled selections. */
- gmx::SelectionList sel;
+ /*! \brief
+ * Array of compiled selections.
+ *
+ * Has the responsibility of managing the memory for the contained objects,
+ * but note that gmx::Selection instances also hold pointers to the
+ * objects.
+ */
+ gmx::SelectionDataList sel;
/** Number of variables defined. */
int nvars;
/** Selection strings for variables. */
* Does not clear \p output.
*/
void runParser(void *scanner, int maxnr,
- std::vector<Selection *> *output);
+ SelectionList *output);
/*! \brief
* Adds a selection request for delayed user input.
*
void
SelectionCollection::Impl::runParser(yyscan_t scanner, int maxnr,
- std::vector<Selection *> *output)
+ SelectionList *output)
{
gmx_ana_selcollection_t *sc = &_sc;
GMX_ASSERT(sc == _gmx_sel_lexer_selcollection(scanner),
if (bOk)
{
- SelectionList::const_iterator i;
+ SelectionDataList::const_iterator i;
for (i = _sc.sel.begin() + oldCount; i != _sc.sel.end(); ++i)
{
- output->push_back(i->get());
+ output->push_back(Selection(i->get()));
}
}
std::fprintf(stderr, "(one selection per line, 'help' for help%s)\n",
request.count() < 0 ? ", Ctrl-D to end" : "");
}
- std::vector<Selection *> selections;
+ SelectionList selections;
parseFromStdin(request.count(), bInteractive, &selections);
request.storage->addSelections(selections, true);
}
{
Impl::RequestsClearer clearRequestsOnExit(&_impl->_requests);
- std::vector<Selection *> selections;
+ SelectionList selections;
parseFromString(str, &selections);
- std::vector<Selection *>::const_iterator first = selections.begin();
- std::vector<Selection *>::const_iterator last = first;
+ SelectionList::const_iterator first = selections.begin();
+ SelectionList::const_iterator last = first;
Impl::RequestList::const_iterator i;
for (i = _impl->_requests.begin(); i != _impl->_requests.end(); ++i)
{
}
last = selections.end();
}
- std::vector<Selection *> curr(first, last);
+ SelectionList curr(first, last);
request.storage->addSelections(curr, true);
first = last;
}
void
SelectionCollection::parseFromStdin(int nr, bool bInteractive,
- std::vector<Selection *> *output)
+ SelectionList *output)
{
yyscan_t scanner;
void
SelectionCollection::parseFromFile(const std::string &filename,
- std::vector<Selection *> *output)
+ SelectionList *output)
{
yyscan_t scanner;
FILE *fp;
void
SelectionCollection::parseFromString(const std::string &str,
- std::vector<Selection *> *output)
+ SelectionList *output)
{
yyscan_t scanner;
#include "../legacyheaders/typedefs.h"
#include "../utility/common.h"
+#include "selection.h" // For gmx::SelectionList
struct gmx_ana_indexgrps_t;
struct gmx_ana_poscalc_coll_t;
{
class Options;
-class Selection;
class SelectionCompiler;
class SelectionEvaluator;
class SelectionOptionStorage;
* compile() has been called.
*/
void parseFromStdin(int count, bool bInteractive,
- std::vector<Selection *> *output);
+ SelectionList *output);
/*! \brief
* Parses selection(s) from a file.
*
* compile() has been called.
*/
void parseFromFile(const std::string &filename,
- std::vector<Selection *> *output);
+ SelectionList *output);
/*! \brief
* Parses selection(s) from a string.
*
* compile() has been called.
*/
void parseFromString(const std::string &str,
- std::vector<Selection *> *output);
+ SelectionList *output);
/*! \brief
* Prepares the selections for evaluation and performs optimizations.
*
std::string SelectionOptionStorage::formatValue(int i) const
{
- Selection *sel = values().at(i);
- return (sel != NULL ? sel->selectionText() : "");
+ return values()[i].selectionText();
}
void SelectionOptionStorage::addSelections(
- const std::vector<Selection *> &selections,
+ const SelectionList &selections,
bool bFullValue)
{
if (bFullValue && selections.size() < static_cast<size_t>(minValueCount()))
{
clearSet();
}
- std::vector<Selection *>::const_iterator i;
+ SelectionList::const_iterator i;
for (i = selections.begin(); i != selections.end(); ++i)
{
// TODO: Having this check in the parser would make interactive input
// behave better.
- if (_selectionFlags.test(efOnlyStatic) && (*i)->isDynamic())
+ if (_selectionFlags.test(efOnlyStatic) && i->isDynamic())
{
GMX_THROW(InvalidInputError("Dynamic selections not supported"));
}
- (*i)->setFlags(_selectionFlags);
addValue(*i);
}
if (bFullValue)
{
GMX_RELEASE_ASSERT(_sc != NULL, "Selection collection is not set");
- std::vector<Selection *> selections;
+ SelectionList selections;
// TODO: Implement reading from a file.
_sc->parseFromString(value, &selections);
addSelections(selections, false);
{
GMX_THROW(InvalidInputError("Too few (valid) values provided"));
}
+ ValueList::iterator i;
+ for (i = values->begin(); i != values->end(); ++i)
+ {
+ i->data().setFlags(_selectionFlags);
+ }
}
void SelectionOptionStorage::processAll()
void SelectionOptionStorage::setSelectionFlag(SelectionFlag flag, bool bSet)
{
_selectionFlags.set(flag, bSet);
- ValueList::const_iterator i;
+ ValueList::iterator i;
for (i = values().begin(); i != values().end(); ++i)
{
- if (_selectionFlags.test(efOnlyStatic) && (*i)->isDynamic())
+ if (_selectionFlags.test(efOnlyStatic) && i->isDynamic())
{
MessageStringCollector errors;
errors.startContext("In option '" + name() + "'");
errors.finishContext();
GMX_THROW(InvalidInputError(errors.toString()));
}
- (*i)->setFlags(_selectionFlags);
+ i->data().setFlags(_selectionFlags);
}
}
#define GMX_SELECTION_SELECTIONOPTION_H
#include "../options/abstractoption.h"
+#include "selection.h"
#include "selectionenums.h"
namespace gmx
{
-class Selection;
class SelectionOptionInfo;
class SelectionOptionStorage;
* \inpublicapi
* \ingroup module_selection
*/
-class SelectionOption : public OptionTemplate<Selection *, SelectionOption>
+class SelectionOption : public OptionTemplate<Selection, SelectionOption>
{
public:
//! Initializes an option with the given name.
*
* Example use:
* \code
-std::vector<Selection *> sel;
+SelectionList sel;
Options options("example", "Example options");
SelectionOptionInfo *info;
options.addOption(SelectionOption("sel").storeVector(&sel)
#define GMX_SELECTION_SELECTIONOPTIONSTORAGE_H
#include "../options/optionstoragetemplate.h"
+#include "selection.h"
#include "selectionenums.h"
#include "selectionoptioninfo.h"
namespace gmx
{
-class Selection;
class SelectionCollection;
class SelectionOption;
*
* \ingroup module_selection
*/
-class SelectionOptionStorage : public OptionStorageTemplate<Selection *>
+class SelectionOptionStorage : public OptionStorageTemplate<Selection>
{
public:
/*! \brief
* \p bFullValue set to true), as well as internally by the storage
* class (called with \p bFullValue set to false).
*/
- void addSelections(const std::vector<Selection *> &selections,
+ void addSelections(const SelectionList &selections,
bool bFullValue);
// Required to access the number of values in selection requests.
#include <config.h>
#endif
-#include <vector>
-
#include <gtest/gtest.h>
#include "smalloc.h"
void loadTopology(const char *filename);
gmx::SelectionCollection _sc;
- std::vector<gmx::Selection *> _sel;
+ gmx::SelectionList _sel;
t_topology *_top;
t_trxframe *_frame;
};
private:
static void checkSelection(gmx::test::TestReferenceChecker *checker,
- const gmx::Selection *sel, TestFlags flags);
+ const gmx::Selection &sel, TestFlags flags);
void runParser(const char *const *selections);
void runCompiler();
void
SelectionCollectionDataTest::checkSelection(
gmx::test::TestReferenceChecker *checker,
- const gmx::Selection *sel, TestFlags flags)
+ const gmx::Selection &sel, TestFlags flags)
{
using gmx::test::TestReferenceChecker;
{
- gmx::ConstArrayRef<int> atoms = sel->atomIndices();
+ gmx::ConstArrayRef<int> atoms = sel.atomIndices();
checker->checkSequence(atoms.begin(), atoms.end(), "Atoms");
}
if (flags.test(efTestPositionAtoms)
|| flags.test(efTestPositionCoordinates))
{
TestReferenceChecker compound(
- checker->checkSequenceCompound("Positions", sel->posCount()));
- for (int i = 0; i < sel->posCount(); ++i)
+ checker->checkSequenceCompound("Positions", sel.posCount()));
+ for (int i = 0; i < sel.posCount(); ++i)
{
TestReferenceChecker poscompound(compound.checkCompound("Position", NULL));
- gmx::SelectionPosition p = sel->position(i);
+ const gmx::SelectionPosition &p = sel.position(i);
if (flags.test(efTestPositionAtoms))
{
gmx::ConstArrayRef<int> atoms = p.atomIndices();
TestReferenceChecker selcompound(
compound.checkCompound("ParsedSelection", id.c_str()));
selcompound.checkString(selections[i], "Input");
- selcompound.checkString(_sel[_count]->name(), "Name");
- selcompound.checkString(_sel[_count]->selectionText(), "Text");
- selcompound.checkBoolean(_sel[_count]->isDynamic(), "Dynamic");
+ selcompound.checkString(_sel[_count].name(), "Name");
+ selcompound.checkString(_sel[_count].selectionText(), "Text");
+ selcompound.checkBoolean(_sel[_count].isDynamic(), "Dynamic");
++_count;
}
}
for (size_t i = 0; i < _count; ++i)
{
SCOPED_TRACE(std::string("Checking selection \"") +
- _sel[i]->selectionText() + "\"");
+ _sel[i].selectionText() + "\"");
std::string id = gmx::formatString("Selection%d", static_cast<int>(i + 1));
TestReferenceChecker selcompound(
compound.checkCompound("Selection", id.c_str()));
for (size_t i = 0; i < _count; ++i)
{
SCOPED_TRACE(std::string("Checking selection \"") +
- _sel[i]->selectionText() + "\"");
+ _sel[i].selectionText() + "\"");
std::string id = gmx::formatString("Selection%d", static_cast<int>(i + 1));
TestReferenceChecker selcompound(
compound.checkCompound("Selection", id.c_str()));
* \author Teemu Murtola <teemu.murtola@cbr.su.se>
* \ingroup module_selection
*/
-#include <vector>
-
#include <gtest/gtest.h>
#include "gromacs/fatalerror/exceptions.h"
TEST_F(SelectionOptionTest, ParsesSimpleSelection)
{
- gmx::Selection *sel = NULL;
+ gmx::Selection sel;
using gmx::SelectionOption;
ASSERT_NO_THROW(_options.addOption(SelectionOption("sel").store(&sel)));
setCollection();
EXPECT_NO_THROW(assigner.finish());
EXPECT_NO_THROW(_options.finish());
- ASSERT_TRUE(sel != NULL);
- ASSERT_FALSE(sel->isDynamic());
+ ASSERT_FALSE(sel.isDynamic());
}
TEST_F(SelectionOptionTest, HandlesDynamicSelectionWhenStaticRequired)
{
- gmx::Selection *sel = NULL;
+ gmx::Selection sel;
using gmx::SelectionOption;
ASSERT_NO_THROW(_options.addOption(
SelectionOption("sel").store(&sel).onlyStatic()));
TEST_F(SelectionOptionTest, HandlesTooManySelections)
{
- gmx::Selection *sel = NULL;
+ gmx::Selection sel;
using gmx::SelectionOption;
ASSERT_NO_THROW(_options.addOption(SelectionOption("sel").store(&sel)));
setCollection();
EXPECT_NO_THROW(assigner.finishOption());
EXPECT_NO_THROW(assigner.finish());
EXPECT_NO_THROW(_options.finish());
- ASSERT_TRUE(sel != NULL);
+ ASSERT_STREQ("resname RA RB", sel.selectionText());
}
TEST_F(SelectionOptionTest, HandlesTooFewSelections)
{
- gmx::Selection *sel[2] = {NULL, NULL};
+ gmx::Selection sel[2];
using gmx::SelectionOption;
ASSERT_NO_THROW(_options.addOption(
SelectionOption("sel").store(sel).valueCount(2)));
TEST_F(SelectionOptionTest, HandlesAdjuster)
{
- std::vector<gmx::Selection *> sel;
+ gmx::SelectionList sel;
gmx::SelectionOptionInfo *info;
using gmx::SelectionOption;
ASSERT_NO_THROW(_options.addOption(
TEST_F(SelectionOptionTest, HandlesDynamicWhenStaticRequiredWithAdjuster)
{
- gmx::Selection *sel;
+ gmx::Selection sel;
gmx::SelectionOptionInfo *info;
using gmx::SelectionOption;
ASSERT_NO_THROW(_options.addOption(
TEST_F(SelectionOptionTest, HandlesTooManySelectionsWithAdjuster)
{
- std::vector<gmx::Selection *> sel;
+ gmx::SelectionList sel;
gmx::SelectionOptionInfo *info;
using gmx::SelectionOption;
ASSERT_NO_THROW(_options.addOption(
TEST_F(SelectionOptionTest, HandlesTooFewSelectionsWithAdjuster)
{
- std::vector<gmx::Selection *> sel;
+ gmx::SelectionList sel;
gmx::SelectionOptionInfo *info;
using gmx::SelectionOption;
ASSERT_NO_THROW(_options.addOption(
TEST_F(SelectionOptionTest, HandlesDelayedRequiredSelection)
{
- gmx::Selection *sel = NULL;
+ gmx::Selection sel;
using gmx::SelectionOption;
ASSERT_NO_THROW(_options.addOption(
SelectionOption("sel").store(&sel).required()));
EXPECT_NO_THROW(assigner.finish());
EXPECT_NO_THROW(_options.finish());
EXPECT_NO_THROW(_sc.parseRequestedFromString("resname RA RB"));
- ASSERT_TRUE(sel != NULL);
+ ASSERT_STREQ("resname RA RB", sel.selectionText());
}
TEST_F(SelectionOptionTest, HandlesTooFewDelayedRequiredSelections)
{
- gmx::Selection *sel[2] = {NULL, NULL};
+ gmx::Selection sel[2];
using gmx::SelectionOption;
ASSERT_NO_THROW(_options.addOption(
SelectionOption("sel").store(sel).required()
TEST_F(SelectionOptionTest, HandlesDelayedOptionalSelection)
{
- gmx::Selection *sel = NULL;
+ gmx::Selection sel;
using gmx::SelectionOption;
ASSERT_NO_THROW(_options.addOption(SelectionOption("sel").store(&sel)));
setCollection();
EXPECT_NO_THROW(assigner.finish());
EXPECT_NO_THROW(_options.finish());
EXPECT_NO_THROW(_sc.parseRequestedFromString("resname RA RB"));
- ASSERT_TRUE(sel != NULL);
+ ASSERT_STREQ("resname RA RB", sel.selectionText());
}
TEST_F(SelectionOptionTest, HandlesDelayedSelectionWithAdjuster)
{
- std::vector<gmx::Selection *> sel;
+ gmx::SelectionList sel;
gmx::SelectionOptionInfo *info;
using gmx::SelectionOption;
ASSERT_NO_THROW(_options.addOption(
#include "gromacs/analysisdata/analysisdata.h"
#include "gromacs/fatalerror/exceptions.h"
#include "gromacs/fatalerror/gmxassert.h"
+#include "gromacs/selection/selection.h"
#include "analysismodule-impl.h"
}
-Selection *TrajectoryAnalysisModuleData::parallelSelection(Selection *selection)
+Selection TrajectoryAnalysisModuleData::parallelSelection(const Selection &selection)
{
// TODO: Implement properly.
return selection;
}
-std::vector<Selection *>
-TrajectoryAnalysisModuleData::parallelSelections(const std::vector<Selection *> &selections)
+SelectionList
+TrajectoryAnalysisModuleData::parallelSelections(const SelectionList &selections)
{
- std::vector<Selection *> newSelections;
+ // TODO: Consider an implementation that does not allocate memory every time.
+ SelectionList newSelections;
newSelections.reserve(selections.size());
- std::vector<Selection *>::const_iterator i = selections.begin();
+ SelectionList::const_iterator i = selections.begin();
for ( ; i != selections.end(); ++i)
{
newSelections.push_back(parallelSelection(*i));
#include "../legacyheaders/typedefs.h"
+#include "../selection/selection.h" // For gmx::SelectionList
#include "../utility/common.h"
#include "../utility/uniqueptr.h"
class AnalysisDataHandle;
class AnalysisDataParallelOptions;
class Options;
-class Selection;
class SelectionCollection;
class TopologyInformation;
class TrajectoryAnalysisModule;
/*! \brief
* Returns a selection that corresponds to the given selection.
*/
- Selection *parallelSelection(Selection *selection);
+ Selection parallelSelection(const Selection &selection);
/*! \brief
* Returns a set of selection that corresponds to the given selections.
*/
- std::vector<Selection *> parallelSelections(const std::vector<Selection *> &selections);
+ SelectionList parallelSelections(const SelectionList &selections);
protected:
/*! \brief
void
-Angle::checkSelections(const std::vector<Selection *> &sel1,
- const std::vector<Selection *> &sel2) const
+Angle::checkSelections(const SelectionList &sel1,
+ const SelectionList &sel2) const
{
if (_bMulti)
{
for (size_t g = 0; g < sel1.size(); ++g)
{
- if (sel1[g]->posCount() % _natoms1 != 0)
+ if (sel1[g].posCount() % _natoms1 != 0)
{
GMX_THROW(InconsistentInputError(formatString(
"Number of positions in selection %d not divisible by %d",
return;
}
- int na1 = sel1[0]->posCount();
- int na2 = (_natoms2 > 0) ? sel2[0]->posCount() : 0;
+ int na1 = sel1[0].posCount();
+ int na2 = (_natoms2 > 0) ? sel2[0].posCount() : 0;
if (!_bSplit1 && _natoms1 > 1 && na1 % _natoms1 != 0)
{
{
for (int g = 1; g < _natoms1; ++g)
{
- if (sel1[g]->posCount() != na1)
+ if (sel1[g].posCount() != na1)
{
GMX_THROW(InconsistentInputError(
"All selections in the first group should contain "
{
for (int g = 1; g < _natoms2; ++g)
{
- if (sel2[g]->posCount() != na2)
+ if (sel2[g].posCount() != na2)
{
GMX_THROW(InconsistentInputError(
"All selections in the second group should contain "
GMX_THROW(InconsistentInputError(
"Number of vectors defined by the two groups are not the same"));
}
- if (_g2type[0] == 's' && sel2[0]->posCount() != 1)
+ if (_g2type[0] == 's' && sel2[0].posCount() != 1)
{
GMX_THROW(InconsistentInputError(
"The second group should contain a single position with -g2 sphnorm"));
}
else if (_bAll)
{
- int na = _sel1[0]->posCount();
+ int na = _sel1[0].posCount();
if (!_bSplit1)
{
na /= _natoms1;
if (_g2type == "t0")
{
- int na = _sel1[0]->posCount();
+ int na = _sel1[0].posCount();
if (!_bSplit1)
{
na /= _natoms1;
static void
-copy_pos(const std::vector<Selection *> &sel, bool bSplit, int natoms,
+copy_pos(const SelectionList &sel, bool bSplit, int natoms,
int firstg, int first, rvec x[])
{
if (bSplit)
{
for (int k = 0; k < natoms; ++k)
{
- copy_rvec(sel[firstg + k]->position(first).x(), x[k]);
+ copy_rvec(sel[firstg + k].position(first).x(), x[k]);
}
}
else
{
for (int k = 0; k < natoms; ++k)
{
- copy_rvec(sel[firstg]->position(first + k).x(), x[k]);
+ copy_rvec(sel[firstg].position(first + k).x(), x[k]);
}
}
}
TrajectoryAnalysisModuleData *pdata)
{
AnalysisDataHandle dh = pdata->dataHandle(_data);
- std::vector<Selection *> sel1 = pdata->parallelSelections(_sel1);
- std::vector<Selection *> sel2 = pdata->parallelSelections(_sel2);
+ const SelectionList &sel1 = pdata->parallelSelections(_sel1);
+ const SelectionList &sel2 = pdata->parallelSelections(_sel2);
checkSelections(sel1, sel2);
clear_rvec(c2);
break;
case 's':
- copy_rvec(_sel2[0]->position(0).x(), c2);
+ copy_rvec(_sel2[0].position(0).x(), c2);
break;
}
real ave = 0.0;
int n = 0;
int i, j;
- for (i = j = 0; i < sel1[g]->posCount(); i += incr1)
+ for (i = j = 0; i < sel1[g].posCount(); i += incr1)
{
rvec x[4];
real angle;
#define GMX_TRAJECTORYANALYSIS_MODULES_ANGLE_H
#include <string>
-#include <vector>
#include "../analysismodule.h"
#include "gromacs/analysisdata/analysisdata.h"
#include "gromacs/options/options.h"
+#include "gromacs/selection/selection.h"
namespace gmx
{
-class Selection;
class SelectionOptionInfo;
namespace analysismodules
virtual void writeOutput();
private:
- void checkSelections(const std::vector<Selection *> &sel1,
- const std::vector<Selection *> &sel2) const;
+ void checkSelections(const SelectionList &sel1,
+ const SelectionList &sel2) const;
Options _options;
- std::vector<Selection *> _sel1;
- std::vector<Selection *> _sel2;
+ SelectionList _sel1;
+ SelectionList _sel2;
SelectionOptionInfo *_sel1info;
SelectionOptionInfo *_sel2info;
std::string _fnAngle;
Distance::Distance()
: _options("distance", "Distance calculation"), _avem(new AnalysisDataAverageModule())
{
- _sel[0] = _sel[1] = NULL;
}
Distance::initAnalysis(const TrajectoryAnalysisSettings &settings,
const TopologyInformation & /*top*/)
{
- if (_sel[0]->posCount() != 1)
+ if (_sel[0].posCount() != 1)
{
GMX_THROW(InvalidInputError("The first selection does not define a single position"));
}
- if (_sel[1]->posCount() != 1)
+ if (_sel[1].posCount() != 1)
{
GMX_THROW(InvalidInputError("The second selection does not define a single position"));
}
TrajectoryAnalysisModuleData *pdata)
{
AnalysisDataHandle dh = pdata->dataHandle(_data);
- Selection *sel1 = pdata->parallelSelection(_sel[0]);
- Selection *sel2 = pdata->parallelSelection(_sel[1]);
+ const Selection &sel1 = pdata->parallelSelection(_sel[0]);
+ const Selection &sel2 = pdata->parallelSelection(_sel[1]);
rvec dx;
real r;
- SelectionPosition p1 = sel1->position(0);
- SelectionPosition p2 = sel2->position(0);
+ const SelectionPosition &p1 = sel1.position(0);
+ const SelectionPosition &p2 = sel2.position(0);
if (pbc != NULL)
{
#define GMX_TRAJECTORYANALYSIS_MODULES_DISTANCE_H
#include <string>
-#include <vector>
#include "../analysismodule.h"
#include "gromacs/analysisdata/analysisdata.h"
#include "gromacs/analysisdata/modules/average.h"
#include "gromacs/options/options.h"
+#include "gromacs/selection/selection.h"
namespace gmx
{
-class Selection;
-
namespace analysismodules
{
private:
Options _options;
std::string _fnDist;
- Selection *_sel[2];
+ Selection _sel[2];
AnalysisData _data;
AnalysisDataAverageModulePointer _avem;
}
_bResInd = (_resNumberType == "index");
- for (std::vector<Selection *>::const_iterator i = _sel.begin(); i != _sel.end(); ++i)
+ for (SelectionList::iterator i = _sel.begin(); i != _sel.end(); ++i)
{
- (*i)->initCoveredFraction(CFRAC_SOLIDANGLE);
+ i->initCoveredFraction(CFRAC_SOLIDANGLE);
}
// TODO: For large systems, a float may not have enough precision
snew(_totsize, _sel.size());
for (size_t g = 0; g < _sel.size(); ++g)
{
- _totsize[g] = _bTotNorm ? _sel[g]->posCount() : 1;
+ _totsize[g] = _bTotNorm ? _sel[g].posCount() : 1;
}
if (!_fnSize.empty())
{
writer->setFileName(_fnNdx);
for (size_t g = 0; g < _sel.size(); ++g)
{
- writer->addGroup(_sel[g]->name(), _sel[g]->isDynamic());
+ writer->addGroup(_sel[g].name(), _sel[g].isDynamic());
}
_idata.addModule(writer);
}
- _mdata.setColumns(_sel[0]->posCount());
+ _mdata.setColumns(_sel[0].posCount());
registerAnalysisDataset(&_mdata, "mask");
if (!_fnMask.empty())
{
{
fprintf(stderr, "WARNING: the mask (-om) will only be written for the first group\n");
}
- if (!_sel[0]->isDynamic())
+ if (!_sel[0].isDynamic())
{
fprintf(stderr, "WARNING: will not write the mask (-om) for a static selection\n");
}
{
ModuleData *pdata = new ModuleData(this, opt, selections);
snew(pdata->_mmap, 1);
- gmx_ana_indexmap_init(pdata->_mmap, pdata->parallelSelection(_sel[0])->indexGroup(),
- _top, _sel[0]->type());
+ gmx_ana_indexmap_init(pdata->_mmap, pdata->parallelSelection(_sel[0]).indexGroup(),
+ _top, _sel[0].type());
return TrajectoryAnalysisModuleDataPointer(pdata);
}
AnalysisDataHandle cdh = pdata->dataHandle(_cdata);
AnalysisDataHandle idh = pdata->dataHandle(_idata);
AnalysisDataHandle mdh = pdata->dataHandle(_mdata);
- std::vector<Selection *> sel(pdata->parallelSelections(_sel));
+ const SelectionList &sel = pdata->parallelSelections(_sel);
sdh.startFrame(frnr, fr.time);
for (size_t g = 0; g < sel.size(); ++g)
{
- real normfac = _bFracNorm ? 1.0 / sel[g]->coveredFraction() : 1.0;
+ real normfac = _bFracNorm ? 1.0 / sel[g].coveredFraction() : 1.0;
normfac /= _totsize[g];
- sdh.setPoint(g, sel[g]->posCount() * normfac);
+ sdh.setPoint(g, sel[g].posCount() * normfac);
}
sdh.finishFrame();
cdh.startFrame(frnr, fr.time);
for (size_t g = 0; g < sel.size(); ++g)
{
- cdh.setPoint(g, sel[g]->coveredFraction());
+ cdh.setPoint(g, sel[g].coveredFraction());
}
cdh.finishFrame();
idh.startFrame(frnr, fr.time);
for (size_t g = 0; g < sel.size(); ++g)
{
- idh.setPoint(0, sel[g]->posCount());
+ idh.setPoint(0, sel[g].posCount());
idh.finishPointSet();
- for (int i = 0; i < sel[g]->posCount(); ++i)
+ for (int i = 0; i < sel[g].posCount(); ++i)
{
- SelectionPosition p = sel[g]->position(i);
- if (sel[g]->type() == INDEX_RES && !_bResInd)
+ const SelectionPosition &p = sel[g].position(i);
+ if (sel[g].type() == INDEX_RES && !_bResInd)
{
idh.setPoint(1, _top->atoms.resinfo[p.mappedId()].nr);
}
}
idh.finishFrame();
- gmx_ana_indexmap_update(d->_mmap, sel[0]->indexGroup(), true);
+ gmx_ana_indexmap_update(d->_mmap, sel[0].indexGroup(), true);
mdh.startFrame(frnr, fr.time);
for (int b = 0; b < d->_mmap->nr; ++b)
{
#define GMX_TRAJECTORYANALYSIS_MODULES_SELECT_H
#include <string>
-#include <vector>
#include "../analysismodule.h"
#include "gromacs/analysisdata/analysisdata.h"
#include "gromacs/options/options.h"
+#include "gromacs/selection/selection.h"
namespace gmx
{
-class AnalysisDataPlotModule;
-class Selection;
-
namespace analysismodules
{
class ModuleData;
Options _options;
- std::vector<Selection *> _sel;
+ SelectionList _sel;
std::string _fnSize;
std::string _fnFrac;
AnalysisData _cdata;
AnalysisData _idata;
AnalysisData _mdata;
- std::vector<std::string> _modnames;
};
} // namespace analysismodules
#include <config.h>
#endif
-#include <vector>
-
#include <gromacs/fatalerror/exceptions.h>
#include <gromacs/options/basicoptions.h>
#include <gromacs/options/options.h>
void printSelections();
Options _options;
- std::vector<Selection *> _selections;
+ SelectionList _selections;
int _nmaxind;
};
fprintf(stderr, "\nSelections:\n");
for (size_t g = 0; g < _selections.size(); ++g)
{
- _selections[g]->printDebugInfo(stderr, _nmaxind);
+ _selections[g].printDebugInfo(stderr, _nmaxind);
}
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
for (size_t g = 0; g < _selections.size(); ++g)
{
- const Selection *sel = _selections[g];
+ const Selection &sel = _selections[g];
- gmx_ana_index_dump(stderr, sel->indexGroup(), g, _nmaxind);
- fprintf(stderr, " Positions (%d pcs):\n", sel->posCount());
- int n = sel->posCount();
+ gmx_ana_index_dump(stderr, sel.indexGroup(), g, _nmaxind);
+ fprintf(stderr, " Positions (%d pcs):\n", sel.posCount());
+ int n = sel.posCount();
if (_nmaxind >= 0 && n > _nmaxind)
{
n = _nmaxind;
}
for (int i = 0; i < n; ++i)
{
- SelectionPosition p = sel->position(i);
+ const SelectionPosition &p = sel.position(i);
fprintf(stderr, " (%.2f,%.2f,%.2f) r=%d, m=%d, n=%d\n",
p.x()[XX], p.x()[YY], p.x()[ZZ],
p.refId(), p.mappedId(), p.atomCount());
}
- if (n < sel->posCount())
+ if (n < sel.posCount())
{
fprintf(stderr, " ...\n");
}