Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / coordinateio / enums.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2019, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*! \file
36  * \brief
37  * Enum class defining the different requirements that outputadapters
38  * have for the output file type. OutputManager objects can only be built
39  * with OutputAdapters whose requirements can be implemented with the available input.
40  *
41  * \author Paul Bauer <paul.bauer.q@gmail.com>
42  * \libinternal
43  * \ingroup module_coordinateio
44  */
45 #ifndef GMX_COORDINATEIO_ENUMS_H
46 #define GMX_COORDINATEIO_ENUMS_H
47
48 namespace gmx
49 {
50
51 /*!\brief
52  * The enums here define the flags specifying the requirements
53  * of different outputadapter modules.
54  *
55  * When building the object for deciding on the output to a new coordinate file,
56  * the CoordinateFile object needs to be able to validate that the dependencies of
57  * attached IOutputAdapters are fulfilled. Classes and interfaces that use
58  * the enum can check their dependencies against the information encoded in the
59  * flags and can then perform an appropriate reaction if there is a mismatch.
60  * \todo Use std::bitset<16> for the entries.
61  *
62  * \libinternal
63  * \ingroup module_coordinateio
64  *
65  */
66 enum class CoordinateFileFlags : unsigned long
67 {
68     /*! \brief
69      * Base setting that says that the module has no requirements.
70      *
71      * Sets the flags to default setting to make sure all output methods
72      * are supported.
73      */
74     Base = 1 << 0,
75     /*! \brief
76      * Requires output method to support force output.
77      *
78      * If set, only output methods supporting writing of forces will work,
79      * others will generate an invalid input error.
80      */
81     RequireForceOutput = 1 << 1,
82     /*! \brief
83      * Requires output method to support velocity output.
84      *
85      * If set, only writing to files that support velocity output will succeed.
86      * Other writing methods will generate an error.
87      */
88     RequireVelocityOutput = 1 << 2,
89     /*! \brief
90      * Requires support for connection information in output format.
91      *
92      * If set, only file output that supports writing of connection information will succeed.
93      * This means for now that only PDB and TNG files can be written. Other file writing
94      * methods will fail.
95      */
96     RequireAtomConnections = 1 << 3,
97     /*! \brief
98      * Requires that output format supports the writing of atom information to the file.
99      *
100      * If set, files will only be written if they can output the information from t_atoms
101      * and otherwise create an error while writing.
102      */
103     RequireAtomInformation = 1 << 4,
104     /*! \brief
105      * Requires that output format supports writing user-specified output precision.
106      *
107      * If set, output will only be written if the format supports the writing
108      * of custom precision of the included data.
109      */
110     RequireChangedOutputPrecision = 1 << 5,
111     /*! \brief
112      * Requires that output format supports writing time to the file.
113      */
114     RequireNewFrameStartTime = 1 << 6,
115     /*! \brief
116      * Requires that output format supports writing time to the file.
117      */
118     RequireNewFrameTimeStep = 1 << 7,
119     /*! \brief
120      * Requires that output format supports writing box information.
121      */
122     RequireNewBox = 1 << 8,
123     /*! \brief
124      * Requires output to support changes to selection of coordinates.
125      *
126      * Default for most methods, will need to be able to write coordinates to
127      * output file or generate an error.
128      */
129     RequireCoordinateSelection = 1 << 9,
130     //! Needed for enumeration array.
131     Count
132 };
133
134 //! Conversion of flag to its corresponding unsigned long value.
135 inline unsigned long convertFlag(CoordinateFileFlags flag)
136 {
137     return static_cast<unsigned long>(flag);
138 }
139
140 //! Enum class for setting basic flags in a t_trxframe
141 enum class ChangeSettingType
142 {
143     PreservedIfPresent,
144     Always,
145     Never
146 };
147 //! Mapping for enums from \ref ChangeSettingType.
148 const char* const cChangeSettingTypeEnum[] = { "preserved-if-present", "always", "never" };
149
150 //! Enum class for t_atoms settings
151 enum class ChangeAtomsType
152 {
153     PreservedIfPresent,
154     AlwaysFromStructure,
155     Never,
156     Always
157 };
158
159 //! Mapping for enums from \ref ChangeAtomsType.
160 const char* const cChangeAtomsTypeEnum[] = { "preserved-if-present", "always-from-structure",
161                                              "never", "always" };
162
163 //! Enum class for setting fields new or not.
164 enum class ChangeFrameInfoType
165 {
166     PreservedIfPresent,
167     Always
168 };
169 //! Mapping for enums from \ref ChangeFrameInfoType.
170 const char* const cChangeFrameInfoTypeEnum[] = { "preserved-if-present", "always" };
171
172 //! Enum class for setting frame time from user input.
173 enum class ChangeFrameTimeType
174 {
175     PreservedIfPresent,
176     StartTime,
177     TimeStep,
178     Both
179 };
180
181 //! Mapping for values from \ref ChangeFrameTimeType.
182 const char* const cChangeFrameTimeTypeEnum[] = { "preserved-if-present", "starttime", "timestep",
183                                                  "both" };
184
185
186 } // namespace gmx
187
188 #endif