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;
21
47
55constexpr bool IsUsable(Status status) noexcept
56{
57 return status == Status::OK || status == Status::OUT_OF_RANGE_INACCURATE;
58}
59
64inline Status& operator+=(Status& lhs, Status rhs) noexcept
65{
66 // Keep the first error status
67 if (lhs == Status::OK) lhs = rhs;
68 return lhs;
69}
70
75inline Status& operator&=(Status& lhs, Status rhs) noexcept
76{
77 // Only update if we haven't already failed
78 if (lhs == Status::OK) {
79 lhs = rhs;
80 }
81 return lhs;
82}
83
88inline Status operator&(Status lhs, Status rhs) noexcept
89{
90 lhs &= rhs;
91 return lhs;
92}
94
95struct MARENV_API NoCopyNoMove
96{
98
100
101 NoCopyNoMove() = default;
102 NoCopyNoMove(const NoCopyNoMove&) = delete;
103 NoCopyNoMove& operator=(const NoCopyNoMove&) = delete;
104 NoCopyNoMove(NoCopyNoMove&&) = delete;
105 NoCopyNoMove& operator=(NoCopyNoMove&&) = delete;
107
108};
110
112{
114
115 MoveNoCopy() = default;
116 MoveNoCopy(const MoveNoCopy&) = delete;
117 MoveNoCopy& operator=(const MoveNoCopy&) = delete;
118 MoveNoCopy(MoveNoCopy&&) = default;
119 MoveNoCopy& operator=(MoveNoCopy&&) = default;
121
122};
123
131} // namespace marenv
Status
Definition marenv.h:40
constexpr bool IsUsable(Status status) noexcept
Definition marenv.h:55
@ 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
Not implemented; 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 PorousDiscWakeSource.h:15
Status operator&(Status lhs, Status rhs) noexcept
Definition marenv.h:88
constexpr double gravity
Gravity constant.
Definition marenv.h:19
constexpr double PI
Defines pi.
Definition marenv.h:18
constexpr double seawaterDensity
Ocean water density.
Definition marenv.h:20
Status & operator&=(Status &lhs, Status rhs) noexcept
Definition marenv.h:75
Status & operator+=(Status &lhs, Status rhs) noexcept
Definition marenv.h:64
Policy mixin: this type is default copyable but not movable.
Definition marenv.h:112
Policy mixin: this type is neither copyable nor movable.
Definition marenv.h:96