Merge "Merge remote-tracking branch 'gerrit/release-4-6'"
[alexxy/gromacs.git] / src / gromacs / selection / selectionoption.h
1 /*
2  *
3  *                This source code is part of
4  *
5  *                 G   R   O   M   A   C   S
6  *
7  *          GROningen MAchine for Chemical Simulations
8  *
9  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11  * Copyright (c) 2001-2009, The GROMACS development team,
12  * check out http://www.gromacs.org for more information.
13
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * If you want to redistribute modifications, please consider that
20  * scientific software is very special. Version control is crucial -
21  * bugs must be traceable. We will be happy to consider code for
22  * inclusion in the official distribution, but derived work must not
23  * be called official GROMACS. Details are found in the README & COPYING
24  * files - if they are missing, get the official version at www.gromacs.org.
25  *
26  * To help us fund GROMACS development, we humbly ask that you cite
27  * the papers on the package - you can find them in the top README file.
28  *
29  * For more info, check our website at http://www.gromacs.org
30  */
31 /*! \file
32  * \brief
33  * Declares gmx::SelectionOption.
34  *
35  * \author Teemu Murtola <teemu.murtola@cbr.su.se>
36  * \inpublicapi
37  * \ingroup module_selection
38  */
39 #ifndef GMX_SELECTION_SELECTIONOPTION_H
40 #define GMX_SELECTION_SELECTIONOPTION_H
41
42 #include "../options/abstractoption.h"
43 #include "selection.h"
44 #include "selectionenums.h"
45
46 namespace gmx
47 {
48
49 class SelectionOptionInfo;
50 class SelectionOptionStorage;
51
52 /*! \brief
53  * Specifies an option that provides selection(s).
54  *
55  * Public methods in this class do not throw.
56  *
57  * \inpublicapi
58  * \ingroup module_selection
59  */
60 class SelectionOption : public OptionTemplate<Selection, SelectionOption>
61 {
62     public:
63         //! Initializes an option with the given name.
64         explicit SelectionOption(const char *name)
65             : MyBase(name), infoPtr_(NULL)
66         { }
67
68         /*! \brief
69          * Request velocity evaluation for output positions.
70          *
71          * Note that even with this flag set, velocities may not be available,
72          * in which case SelectionPosition::hasVelocity() returns false.
73          */
74         MyClass &evaluateVelocities()
75         { selectionFlags_.set(efSelection_EvaluateVelocities); return me(); }
76         /*! \brief
77          * Request force evaluation for output positions.
78          *
79          * Note that even with this flag set, forces may not be available,
80          * in which case SelectionPosition::hasForce() returns false.
81          */
82         MyClass &evaluateForces()
83         { selectionFlags_.set(efSelection_EvaluateForces); return me(); }
84         /*! \brief
85          * Only accept selections that evaluate to atom positions.
86          *
87          * TODO: This option is not yet implemented.
88          */
89         MyClass &onlyAtoms()
90         { selectionFlags_.set(efSelection_OnlyAtoms); return me(); }
91         /*! \brief
92          * Only accept static selections for this option.
93          */
94         MyClass &onlyStatic()
95         { selectionFlags_.set(efSelection_OnlyStatic); return me(); }
96         /*! \brief
97          * Handle dynamic selections for this option with position masks.
98          *
99          * \see Selection
100          * \see SelectionPosition::selected()
101          */
102         MyClass &dynamicMask()
103         { selectionFlags_.set(efSelection_DynamicMask); return me(); }
104         /*! \brief
105          * Disallow using atom coordinates as the reference positions.
106          *
107          * TODO: This option is not yet implemented.
108          */
109         MyClass &dynamicOnlyWhole()
110         { selectionFlags_.set(efSelection_DynamicOnlyWhole); return me(); }
111
112         /*! \brief
113          * Get an info object that can be used to alter the option after
114          * creation.
115          *
116          * \see SelectionOptionInfo
117          */
118         MyClass &getAdjuster(SelectionOptionInfo **infoPtr)
119         { infoPtr_ = infoPtr; return me(); }
120
121     private:
122         // Disable possibility to allow multiple occurrences, since it isn't
123         // implemented.
124         using MyBase::allowMultiple;
125         // Disable default value because it is impossible to provide a
126         // Selection object.
127         using MyBase::defaultValue;
128         using MyBase::defaultValueIfSet;
129
130         virtual AbstractOptionStoragePointer createStorage() const;
131
132         SelectionFlags          selectionFlags_;
133         SelectionOptionInfo   **infoPtr_;
134
135         /*! \brief
136          * Needed to initialize SelectionOptionStorage from this class without
137          * otherwise unnecessary accessors.
138          */
139         friend class SelectionOptionStorage;
140 };
141
142 } // namespace gmx
143
144 #endif