World Builder  1.1.0-pre
A geodynamic initial conditions generator
feature_utilities.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2018-2024 by the authors of the World Builder code.
3 
4  This file is part of the World Builder.
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19 
20 
21 #ifndef WORLD_BUILDER_FEATURES_FEATURE_UTILITIES_H
22 #define WORLD_BUILDER_FEATURES_FEATURE_UTILITIES_H
23 
24 #include <limits>
25 #include <vector>
26 
27 #include "world_builder/assert.h"
28 
29 namespace WorldBuilder
30 {
31  namespace Features
32  {
33  namespace FeatureUtilities
34  {
35  enum class Operations
36  {
38  };
39 
44  string_operations_to_enum(const std::string &operation);
45 
46 
50  inline double
51  apply_operation(const Operations operation,
52  const double old_value,
53  const double new_value)
54  {
55  switch (operation)
56  {
59  return new_value;
60  break;
61 
62  case Operations::ADD:
63  return old_value + new_value;
64  break;
65 
67  return old_value - new_value;
68 
69  default:
70  WBAssert(false,"Operation not found.");
71  }
72 
73  return std::numeric_limits<double>::signaling_NaN();
74  }
75 
81  {
82  // The total length of all the segments at the location of the plane.
84 
85  // The local thickness of the segment at the location of the plane.
87  };
88 
89 
94  size_t
95  add_vector_unique(std::vector<std::string> &vector,const std::string &add_string);
96 
97  } // namespace Utilities
98  } // namespace Features
99 } // namespace WorldBuilder
100 
101 #endif
size_t add_vector_unique(std::vector< std::string > &vector, const std::string &add_string)
Operations string_operations_to_enum(const std::string &operation)
#define WBAssert(condition, message)
Definition: assert.h:27
double apply_operation(const Operations operation, const double old_value, const double new_value)