GEOSX
InputFlags.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 Total, S.A
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOSX_DATAREPOSITORY_INPUTFLAGS_HPP_
20 #define GEOSX_DATAREPOSITORY_INPUTFLAGS_HPP_
21 
22 #include "common/DataTypes.hpp"
23 #include "common/Logger.hpp"
24 
25 namespace geosx
26 {
27 
28 namespace dataRepository
29 {
30 
36 enum class InputFlags : integer
37 {
38  INVALID,
39  FALSE,
40  OPTIONAL,
42  REQUIRED,
44  PROBLEM_ROOT,
45 };
46 
52 inline InputFlags IntToInputFlag( int const val )
53 {
55  switch( val )
56  {
57  case 0:
58  {
59  rval = InputFlags::FALSE;
60  break;
61  }
62  case 1:
63  {
64  rval = InputFlags::OPTIONAL;
65  break;
66  }
67  case 2:
68  {
69  rval = InputFlags::REQUIRED;
70  break;
71  }
72  default:
73  {
74  GEOSX_ERROR( "Invalid integer conversion to InputFlag" );
75  }
76  }
77  return rval;
78 }
79 
85 inline int InputFlagToInt( InputFlags const val )
86 {
87  return static_cast< int >(val);
88 }
89 
90 
97 {
98  std::string rval;
99  switch( val )
100  {
101  case InputFlags::INVALID:
102  {
103  rval = "INVALID";
104  break;
105  }
106  case InputFlags::FALSE:
107  {
108  rval = "FALSE";
109  break;
110  }
112  {
113  rval = "OPTIONAL";
114  break;
115  }
117  {
118  rval = "OPTIONAL_NONUNIQUE";
119  break;
120  }
122  {
123  rval = "REQUIRED";
124  break;
125  }
127  {
128  rval = "REQUIRED_NONUNIQUE";
129  break;
130  }
132  {
133  rval = "PROBLEM_ROOT";
134  break;
135  }
136  }
137  return rval;
138 }
139 
146 inline bool operator==( InputFlags const left, InputFlags const right )
147 {
148  return static_cast< int >(left) == static_cast< int >(right);
149 }
150 
154 inline bool operator!=( InputFlags const left, InputFlags const right )
155 {
156  return static_cast< int >(left) != static_cast< int >(right);
157 }
158 
162 inline bool operator<( InputFlags const left, InputFlags const right )
163 {
164  return static_cast< int >(left) < static_cast< int >(right);
165 }
166 
170 inline bool operator>( InputFlags const left, InputFlags const right )
171 {
172  return static_cast< int >(left) > static_cast< int >(right);
173 }
174 
178 inline bool operator<=( InputFlags const left, InputFlags const right )
179 {
180  return static_cast< int >(left) <= static_cast< int >(right);
181 }
182 
186 inline bool operator>=( InputFlags const left, InputFlags const right )
187 {
188  return static_cast< int >(left) >= static_cast< int >(right);
189 }
190 }
191 
192 
193 } /* namespace geosx */
194 
195 
196 
197 #endif /* GEOSX_DATAREPOSITORY_INPUTFLAGS_HPP_ */
bool operator!=(InputFlags const left, InputFlags const right)
Comparison operator for InputFlags enumeration.
Definition: InputFlags.hpp:154
int InputFlagToInt(InputFlags const val)
Convert InputFlags to int.
Definition: InputFlags.hpp:85
InputFlags IntToInputFlag(int const val)
Convert integer value to InputFlags.
Definition: InputFlags.hpp:52
bool operator<(InputFlags const left, InputFlags const right)
Comparison operator for InputFlags enumeration.
Definition: InputFlags.hpp:162
bool operator<=(InputFlags const left, InputFlags const right)
Comparison operator for InputFlags enumeration.
Definition: InputFlags.hpp:178
bool operator>=(InputFlags const left, InputFlags const right)
Comparison operator for InputFlags enumeration.
Definition: InputFlags.hpp:186
std::string InputFlagToString(InputFlags const val)
Convert an InputFlags value to a string.
Definition: InputFlags.hpp:96
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:122
#define GEOSX_ERROR(msg)
Raise a hard error and terminate the program.
Definition: Logger.hpp:110
Required in input, may be repeated.
bool operator==(InputFlags const left, InputFlags const right)
Comparison operator for InputFlags enumeration.
Definition: InputFlags.hpp:146
bool operator>(InputFlags const left, InputFlags const right)
Comparison operator for InputFlags enumeration.
Definition: InputFlags.hpp:170
Optional in input, may be repeated.
std::string string
String type.
Definition: DataTypes.hpp:131