/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* \author Teemu Murtola <teemu.murtola@gmail.com>
* \ingroup module_selection
*/
+#include "gmxpre.h"
+
#include <cctype>
#include <cstring>
#include <boost/shared_ptr.hpp>
#include "gromacs/legacyheaders/macros.h"
-#include "gromacs/legacyheaders/smalloc.h"
-#include "gromacs/legacyheaders/string2.h"
-
-#include "gromacs/selection/selmethod.h"
+#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxregex.h"
#include "gromacs/utility/messagestringcollector.h"
+#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/stringutil.h"
#include "keywords.h"
#include "parsetree.h"
#include "scanner.h"
#include "selelem.h"
+#include "selmethod.h"
-/** Allocates data for integer keyword evaluation. */
+/*! \brief
+ * Allocates data for integer keyword evaluation.
+ *
+ * \param[in] npar Not used.
+ * \param param Not used.
+ * \returns Pointer to the allocated data (\ref t_methoddata_kwint).
+ *
+ * Allocates memory for a \ref t_methoddata_kwint structure.
+ */
static void *
-init_data_kwint(int npar, gmx_ana_selparam_t *param);
-/** Allocates data for real keyword evaluation. */
+init_data_kwint(int npar, gmx_ana_selparam_t * param);
+/*! \brief
+ * Allocates data for real keyword evaluation.
+ *
+ * \param[in] npar Not used.
+ * \param param Not used.
+ * \returns Pointer to the allocated data (\ref t_methoddata_kwreal).
+ *
+ * Allocates memory for a \ref t_methoddata_kwreal structure.
+ */
static void *
-init_data_kwreal(int npar, gmx_ana_selparam_t *param);
-/** Allocates data for string keyword evaluation. */
+init_data_kwreal(int npar, gmx_ana_selparam_t * param);
+/*! \brief
+ * Allocates data for string keyword evaluation.
+ *
+ * \param[in] npar Not used.
+ * \param param Not used.
+ * \returns Pointer to the allocated data (t_methoddata_kwstr).
+ *
+ * Allocates memory for a t_methoddata_kwstr structure.
+ */
static void *
-init_data_kwstr(int npar, gmx_ana_selparam_t *param);
-/** Initializes data for integer keyword evaluation. */
+init_data_kwstr(int npar, gmx_ana_selparam_t * param);
+/** /brief Initializes data for integer keyword evaluation.
+ *
+ * \param[in] top Not used.
+ * \param[in] npar Not used (should be 2).
+ * \param[in] param Method parameters (should point to \ref smparams_keyword_int).
+ * \param[in] data Should point to \ref t_methoddata_kwint.
+ */
static void
init_kwint(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
-/** Initializes data for real keyword evaluation. */
+/*! \brief
+ * Initializes data for real keyword evaluation.
+ *
+ * \param[in] top Not used.
+ * \param[in] npar Not used (should be 2).
+ * \param[in] param Method parameters (should point to \ref smparams_keyword_real).
+ * \param[in] data Should point to \ref t_methoddata_kwreal.
+ * \returns 0 (the initialization always succeeds).
+ */
static void
init_kwreal(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
-/** Initializes data for string keyword evaluation. */
+/*! \brief
+ * Initializes data for string keyword evaluation.
+ *
+ * \param[in] top Not used.
+ * \param[in] npar Not used (should be 2).
+ * \param[in] param Method parameters (should point to \ref smparams_keyword_str).
+ * \param[in] data Should point to t_methoddata_kwstr.
+ */
static void
init_kwstr(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
/** Frees the memory allocated for string keyword evaluation. */
free_data_kwstr(void *data);
/** Evaluates integer selection keywords. */
static void
-evaluate_keyword_int(t_topology *top, t_trxframe *fr, t_pbc *pbc,
+evaluate_keyword_int(t_topology * /* top */, t_trxframe * /* fr */, t_pbc * /* pbc */,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data);
/** Evaluates real selection keywords. */
static void
-evaluate_keyword_real(t_topology *top, t_trxframe *fr, t_pbc *pbc,
+evaluate_keyword_real(t_topology * /* top */, t_trxframe * /* fr */, t_pbc * /* pbc */,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data);
/** Evaluates string selection keywords. */
static void
-evaluate_keyword_str(t_topology *top, t_trxframe *fr, t_pbc *pbc,
+evaluate_keyword_str(t_topology * /* top */, t_trxframe * /* fr */, t_pbc * /* pbc */,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data);
/*! \internal \brief
{NULL, {STR_VALUE, -1, {NULL}}, NULL, SPAR_VARNUM},
};
-/** \internal Selection method data for integer keyword evaluation. */
+/** Selection method data for integer keyword evaluation. */
gmx_ana_selmethod_t sm_keyword_int = {
"kw_int", GROUP_VALUE, SMETH_SINGLEVAL,
asize(smparams_keyword_int), smparams_keyword_int,
{NULL, 0, NULL},
};
-/** \internal Selection method data for real keyword evaluation. */
+/** Selection method data for real keyword evaluation. */
gmx_ana_selmethod_t sm_keyword_real = {
"kw_real", GROUP_VALUE, SMETH_SINGLEVAL,
asize(smparams_keyword_real), smparams_keyword_real,
{NULL, 0, NULL},
};
-/** \internal Selection method data for string keyword evaluation. */
+/** Selection method data for string keyword evaluation. */
gmx_ana_selmethod_t sm_keyword_str = {
"kw_str", GROUP_VALUE, SMETH_SINGLEVAL,
asize(smparams_keyword_str), smparams_keyword_str,
{NULL, 0, NULL},
};
-/** Initializes keyword evaluation for an arbitrary group. */
+/*! \brief
+ * Initializes keyword evaluation for an arbitrary group.
+ *
+ * \param[in] top Not used.
+ * \param[in] npar Not used.
+ * \param[in] param Not used.
+ * \param[in] data Should point to \ref t_methoddata_kweval.
+ * \returns 0 on success, a non-zero error code on return.
+ *
+ * Calls the initialization method of the wrapped keyword.
+ */
static void
-init_kweval(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data);
-/** Initializes output for keyword evaluation in an arbitrary group. */
+init_kweval(t_topology *top, int npar, gmx_ana_selparam_t * param, void *data);
+/*! \brief
+ * Initializes output for keyword evaluation in an arbitrary group.
+ *
+ * \param[in] top Not used.
+ * \param[in,out] out Pointer to output data structure.
+ * \param[in,out] data Should point to \c t_methoddata_kweval.
+ * \returns 0 for success.
+ */
static void
init_output_kweval(t_topology *top, gmx_ana_selvalue_t *out, void *data);
/** Frees the data allocated for keyword evaluation in an arbitrary group. */
init_frame_kweval(t_topology *top, t_trxframe *fr, t_pbc *pbc, void *data);
/** Evaluates keywords in an arbitrary group. */
static void
-evaluate_kweval(t_topology *top, t_trxframe *fr, t_pbc *pbc,
- gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data);
+evaluate_kweval(t_topology *top, t_trxframe *fr, t_pbc *pbc, gmx_ana_index_t * /* g */, gmx_ana_selvalue_t *out, void *data);
/*! \internal \brief
* Data structure for keyword evaluation in arbitrary groups.
* INTEGER KEYWORD EVALUATION
********************************************************************/
-/*!
- * \param[in] npar Not used.
- * \param param Not used.
- * \returns Pointer to the allocated data (\ref t_methoddata_kwint).
- *
- * Allocates memory for a \ref t_methoddata_kwint structure.
- */
static void *
-init_data_kwint(int npar, gmx_ana_selparam_t *param)
+init_data_kwint(int /* npar */, gmx_ana_selparam_t * /* param */)
{
t_methoddata_kwint *data;
return data;
}
-/*!
- * \param[in] top Not used.
- * \param[in] npar Not used (should be 2).
- * \param[in] param Method parameters (should point to \ref smparams_keyword_int).
- * \param[in] data Should point to \ref t_methoddata_kwint.
- */
static void
-init_kwint(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data)
+init_kwint(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
t_methoddata_kwint *d = (t_methoddata_kwint *)data;
* Matching atoms are stored in \p out->u.g.
*/
static void
-evaluate_keyword_int(t_topology *top, t_trxframe *fr, t_pbc *pbc,
+evaluate_keyword_int(t_topology * /* top */, t_trxframe * /* fr */, t_pbc * /* pbc */,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
{
t_methoddata_kwint *d = (t_methoddata_kwint *)data;
* REAL KEYWORD EVALUATION
********************************************************************/
-/*!
- * \param[in] npar Not used.
- * \param param Not used.
- * \returns Pointer to the allocated data (\ref t_methoddata_kwreal).
- *
- * Allocates memory for a \ref t_methoddata_kwreal structure.
- */
static void *
-init_data_kwreal(int npar, gmx_ana_selparam_t *param)
+init_data_kwreal(int /* npar */, gmx_ana_selparam_t * /* param */)
{
t_methoddata_kwreal *data;
return data;
}
-/*!
- * \param[in] top Not used.
- * \param[in] npar Not used (should be 2).
- * \param[in] param Method parameters (should point to \ref smparams_keyword_real).
- * \param[in] data Should point to \ref t_methoddata_kwreal.
- * \returns 0 (the initialization always succeeds).
- */
static void
-init_kwreal(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data)
+init_kwreal(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
t_methoddata_kwreal *d = (t_methoddata_kwreal *)data;
* Matching atoms are stored in \p out->u.g.
*/
static void
-evaluate_keyword_real(t_topology *top, t_trxframe *fr, t_pbc *pbc,
+evaluate_keyword_real(t_topology * /* top */, t_trxframe * /* fr */, t_pbc * /* pbc */,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
{
t_methoddata_kwreal *d = (t_methoddata_kwreal *)data;
* STRING KEYWORD EVALUATION
********************************************************************/
-/*!
- * \param[in] npar Not used.
- * \param param Not used.
- * \returns Pointer to the allocated data (t_methoddata_kwstr).
- *
- * Allocates memory for a t_methoddata_kwstr structure.
- */
static void *
-init_data_kwstr(int npar, gmx_ana_selparam_t *param)
+init_data_kwstr(int /* npar */, gmx_ana_selparam_t * /* param */)
{
t_methoddata_kwstr *data = new t_methoddata_kwstr();
data->matchType = gmx::eStringMatchType_Auto;
_gmx_selelem_set_kwstr_match_type(const gmx::SelectionTreeElementPointer &sel,
gmx::SelectionStringMatchType matchType)
{
- t_methoddata_kwstr *d = (t_methoddata_kwstr *)sel->u.expr.mdata;
+ t_methoddata_kwstr *d = static_cast<t_methoddata_kwstr *>(sel->u.expr.mdata);
if (sel->type != SEL_EXPRESSION || !sel->u.expr.method
|| sel->u.expr.method->name != sm_keyword_str.name)
d->matchType = matchType;
}
-/*!
- * \param[in] top Not used.
- * \param[in] npar Not used (should be 2).
- * \param[in] param Method parameters (should point to \ref smparams_keyword_str).
- * \param[in] data Should point to t_methoddata_kwstr.
- */
static void
-init_kwstr(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data)
+init_kwstr(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
- t_methoddata_kwstr *d = (t_methoddata_kwstr *)data;
+ t_methoddata_kwstr *d = static_cast<t_methoddata_kwstr *>(data);
d->v = param[0].val.u.s;
/* Return if this is not the first time */
static void
free_data_kwstr(void *data)
{
- t_methoddata_kwstr *d = (t_methoddata_kwstr *)data;
+ t_methoddata_kwstr *d = static_cast<t_methoddata_kwstr *>(data);
delete d;
}
* Matching atoms are stored in \p out->u.g.
*/
static void
-evaluate_keyword_str(t_topology *top, t_trxframe *fr, t_pbc *pbc,
+evaluate_keyword_str(t_topology * /* top */, t_trxframe * /* fr */, t_pbc * /* pbc */,
gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
{
- t_methoddata_kwstr *d = (t_methoddata_kwstr *)data;
+ t_methoddata_kwstr *d = static_cast<t_methoddata_kwstr *>(data);
out->u.g->isize = 0;
for (int i = 0; i < g->isize; ++i)
* KEYWORD EVALUATION FOR ARBITRARY GROUPS
********************************************************************/
-/*!
- * \param[in] top Not used.
- * \param[in] npar Not used.
- * \param[in] param Not used.
- * \param[in] data Should point to \ref t_methoddata_kweval.
- * \returns 0 on success, a non-zero error code on return.
- *
- * Calls the initialization method of the wrapped keyword.
- */
static void
-init_kweval(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data)
+init_kweval(t_topology *top, int /* npar */, gmx_ana_selparam_t * /* param */, void *data)
{
t_methoddata_kweval *d = (t_methoddata_kweval *)data;
d->kwmethod->init(top, 0, NULL, d->kwmdata);
}
-/*!
- * \param[in] top Not used.
- * \param[in,out] out Pointer to output data structure.
- * \param[in,out] data Should point to \c t_methoddata_kweval.
- * \returns 0 for success.
- */
static void
-init_output_kweval(t_topology *top, gmx_ana_selvalue_t *out, void *data)
+init_output_kweval(t_topology * /* top */, gmx_ana_selvalue_t *out, void *data)
{
t_methoddata_kweval *d = (t_methoddata_kweval *)data;
*/
static void
evaluate_kweval(t_topology *top, t_trxframe *fr, t_pbc *pbc,
- gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
+ gmx_ana_index_t * /* g */, gmx_ana_selvalue_t *out, void *data)
{
t_methoddata_kweval *d = (t_methoddata_kweval *)data;