/*
+ * This file is part of the GROMACS molecular simulation package.
*
- * This source code is part of
+ * Copyright (c) 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.
*
- * G R O M A C S
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
*
- * GROningen MAchine for Chemical Simulations
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
*
* To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
+ * the research papers on the package. Check out http://www.gromacs.org.
*/
/*! \file
* \brief
* Declares gmx::SelectionOption and gmx::SelectionOptionInfo.
*
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
+ * \author Teemu Murtola <teemu.murtola@gmail.com>
* \inpublicapi
* \ingroup module_selection
*/
#ifndef GMX_SELECTION_SELECTIONOPTION_H
#define GMX_SELECTION_SELECTIONOPTION_H
-#include "../options/abstractoption.h"
-
-#include "selection.h"
-#include "selectionenums.h"
+#include "gromacs/options/abstractoption.h"
+#include "gromacs/selection/selection.h"
+#include "gromacs/selection/selectionenums.h"
namespace gmx
{
*
* Public methods in this class do not throw.
*
+ * To use options of this type, SelectionOptionManager must first be added to
+ * the Options collection. For trajectory analysis tools, the framework takes
+ * care of this.
+ *
* \todo
* Support for specifying that an option accepts, e.g., two to four selections.
* Currently, only a fixed count or any number of selections is possible.
typedef SelectionOptionInfo InfoType;
//! Initializes an option with the given name.
- explicit SelectionOption(const char *name) : MyBase(name) { }
+ explicit SelectionOption(const char *name)
+ : MyBase(name), defaultText_(""),
+ selectionFlags_(efSelection_DisallowEmpty)
+ {
+ }
/*! \brief
* Request velocity evaluation for output positions.
{ selectionFlags_.set(efSelection_EvaluateForces); return me(); }
/*! \brief
* Only accept selections that evaluate to atom positions.
- *
- * TODO: This option is not yet implemented.
*/
MyClass &onlyAtoms()
{ selectionFlags_.set(efSelection_OnlyAtoms); return me(); }
MyClass &dynamicMask()
{ selectionFlags_.set(efSelection_DynamicMask); return me(); }
/*! \brief
- * Disallow using atom coordinates as the reference positions.
+ * Allow specifying an unconditionally empty selection for this option.
*
- * TODO: This option is not yet implemented.
+ * If this option is not set, selections that are unconditionally empty
+ * (i.e., can never match any atoms) result in errors.
+ * Note that even without this option, it is still possible that a
+ * dynamic selection evaluates to zero atoms for some frames.
*/
- MyClass &dynamicOnlyWhole()
- { selectionFlags_.set(efSelection_DynamicOnlyWhole); return me(); }
+ MyClass &allowEmpty()
+ { selectionFlags_.clear(efSelection_DisallowEmpty); return me(); }
+
+ /*! \brief
+ * Sets default selection text for the option.
+ *
+ * If the option is not set by the user, the provided text is parsed as
+ * the value of the selection.
+ */
+ MyClass &defaultSelectionText(const char *text)
+ { defaultText_ = text; return me(); }
private:
// Disable possibility to allow multiple occurrences, since it isn't
using MyBase::defaultValue;
using MyBase::defaultValueIfSet;
- virtual AbstractOptionStoragePointer createStorage() const;
+ virtual AbstractOptionStorage *createStorage(
+ const OptionManagerContainer &managers) const;
+ const char *defaultText_;
SelectionFlags selectionFlags_;
/*! \brief
*/
explicit SelectionOptionInfo(SelectionOptionStorage *option);
- /*! \brief
- * Set manager for handling interaction with other options and the
- * selection collection.
- *
- * \param manager Selection manager to set.
- *
- * This must be called before the values are added.
- *
- * Typically it is called through setManagerForSelectionOptions(),
- * which recursively sets the manager for all selection options in
- * an Options object.
- *
- * Does not throw.
- */
- void setManager(SelectionOptionManager *manager);
-
/*! \brief
* Sets the number of selections allowed for the option.
*
* \param[in] bEnabled If true, the option accepts only positions that
* evaluate to atom positions.
*
- * TODO: This is not yet implemented.
- *
* \see SelectionOption::onlyAtoms()
*/
void setOnlyAtoms(bool bEnabled);
* \see SelectionOption::dynamicMask()
*/
void setDynamicMask(bool bEnabled);
- /*! \brief
- * Sets whether atom coordinates are allowed as reference positions.
- *
- * \param[in] bEnabled If true, the option does not accept atom
- * coordinates as reference positions.
- *
- * TODO: This is not yet implemented.
- *
- * \see SelectionOption::dynamicOnlyWhole()
- */
- void setDynamicOnlyWhole(bool bEnabled);
private:
SelectionOptionStorage &option();