FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
marenv.h
1#pragma once
3
4#if defined(_WIN32) || defined(_WIN64)
5 #ifdef MARENV_EXPORTS
6 #define MARENV_API __declspec(dllexport)
7 #else
8 #define MARENV_API __declspec(dllimport)
9 #endif
10#else
11 #define MARENV_API
12#endif
13
15
16namespace marenv
17{
18constexpr double PI = 3.14159265358979323846;
19constexpr double gravity = 9.81;
20constexpr double seawaterDensity = 1025.0;
21constexpr double airDensity = 1.2;
22
51
59constexpr bool IsUsable(Status status) noexcept
60{
61 return status == Status::OK || status == Status::OUT_OF_RANGE_INACCURATE;
62}
63
64namespace detail
65{
67constexpr int StatusRank(Status status) noexcept
68{
69 if (status == Status::OK) return 0;
70 return status == Status::OUT_OF_RANGE_INACCURATE ? 1 : 2;
71}
72} // namespace detail
73
79inline Status& operator+=(Status& lhs, Status rhs) noexcept
80{
81 // A worse rhs replaces lhs; at equal rank the higher enum value wins (only rank 2 holds more than one status)
82 const int rankRhs = detail::StatusRank(rhs);
83 const int rankLhs = detail::StatusRank(lhs);
84 if (rankRhs > rankLhs || (rankRhs == rankLhs && rhs > lhs)) lhs = rhs;
85 return lhs;
86}
87
93inline Status& operator&=(Status& lhs, Status rhs) noexcept
94{
95 lhs += rhs;
96 return lhs;
97}
98
104inline Status operator&(Status lhs, Status rhs) noexcept
105{
106 lhs &= rhs;
107 return lhs;
108}
110
111struct MARENV_API NoCopyNoMove
112{
114
115 NoCopyNoMove() = default;
116 NoCopyNoMove(const NoCopyNoMove&) = delete;
117 NoCopyNoMove& operator=(const NoCopyNoMove&) = delete;
118 NoCopyNoMove(NoCopyNoMove&&) = delete;
119 NoCopyNoMove& operator=(NoCopyNoMove&&) = delete;
121
122};
124
126{
128
129 MoveNoCopy() = default;
130 MoveNoCopy(const MoveNoCopy&) = delete;
131 MoveNoCopy& operator=(const MoveNoCopy&) = delete;
132 MoveNoCopy(MoveNoCopy&&) = default;
133 MoveNoCopy& operator=(MoveNoCopy&&) = default;
135
136};
137
145} // namespace marenv
Status
Definition marenv.h:44
constexpr bool IsUsable(Status status) noexcept
Definition marenv.h:59
@ OUT_OF_RANGE_INACCURATE
The query lay outside the data, and the value was clamped to its edge (a depth profile above its firs...
@ ERROR_NOT_SET
No valid data (outside a field's horizontal extent, a NaN position, no field); the value is not set (...
@ NOT_IMPLEMENTED
Reserved: no marenv method returns it at present. The value is not set.
@ NOT_APPLICABLE_NOT_SET
The quantity does not apply here or is not configured; the value is not set (zero).
@ OK
The value is valid.
The marenv root namespace.
Definition CastPath.h:36
Status operator&(Status lhs, Status rhs) noexcept
Definition marenv.h:104
constexpr double gravity
Gravity constant [m/s^2].
Definition marenv.h:19
constexpr double PI
Defines pi.
Definition marenv.h:18
constexpr double seawaterDensity
Ocean water density [kg/m^3].
Definition marenv.h:20
constexpr double airDensity
Air density [kg/m^3].
Definition marenv.h:21
Status & operator&=(Status &lhs, Status rhs) noexcept
Definition marenv.h:93
Status & operator+=(Status &lhs, Status rhs) noexcept
Definition marenv.h:79
Policy mixin: this type is movable but not copyable.
Definition marenv.h:126
Policy mixin: this type is neither copyable nor movable.
Definition marenv.h:112