INSTINCT Code Coverage Report


Directory: src/
File: Navigation/GNSS/Core/Code.hpp
Date: 2025-02-07 16:54:41
Exec Total Coverage
Lines: 9 9 100.0%
Functions: 7 7 100.0%
Branches: 1 2 50.0%

Line Branch Exec Source
1 // This file is part of INSTINCT, the INS Toolkit for Integrated
2 // Navigation Concepts and Training by the Institute of Navigation of
3 // the University of Stuttgart, Germany.
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9 /// @file Code.hpp
10 /// @brief Code definitions
11 /// @author T. Topp (topp@ins.uni-stuttgart.de)
12 /// @date 2022-06-01
13
14 #pragma once
15
16 #include <bitset>
17 #include <cstdint>
18 #include <fmt/format.h>
19
20 #include "Navigation/GNSS/Core/SatelliteSystem.hpp"
21 #include "Navigation/GNSS/Core/Frequency.hpp"
22
23 namespace NAV
24 {
25
26 /// @brief Enumerate for GNSS Codes
27 ///
28 /// <table>
29 /// <tr><th> System <th> Band <th> Code <th> Description
30 /// <tr><td rowspan="16" valign="top"> GPS <td rowspan="7" valign="top"> L1 <td> L1C <td> C/A-code
31 /// <tr> <td> L1S, L1L, L1X <td> L1C (data, pilot, combined)
32 /// <tr> <td> L1P <td> P-code (unencrypted)
33 /// <tr> <td> L1W <td> Semicodeless P(Y) tracking (Z-tracking)
34 /// <tr> <td> L1Y <td> Y-code (with decryption)
35 /// <tr> <td> L1M <td> M-code
36 /// <tr> <td> L1N <td> codeless
37 /// <tr> <td rowspan="8" valign="top"> L2 <td> L2C <td> C/A-code
38 /// <tr> <td> L2D <td> Semi-codeless P(Y) tracking (L1 C/A+(P2-P1))
39 /// <tr> <td> L2S, L2L, L2X <td> L2C-code (medium, long, combined)
40 /// <tr> <td> L2P <td> P-code (unencrypted)
41 /// <tr> <td> L2W <td> Semicodeless P(Y) tracking (Z-tracking)
42 /// <tr> <td> L2Y <td> Y-code (with decryption)
43 /// <tr> <td> L2M <td> M-code
44 /// <tr> <td> L2N <td> codeless
45 /// <tr> <td> L5 <td> L5I, L5Q, L5X <td> L5 (data, pilot, combined)
46 /// <tr><td rowspan= "7" valign="top"> Galileo <td rowspan="3" valign="top"> E1 <td> L1A <td> PRS signal
47 /// <tr> <td> L1B, L1C, L1X <td> OS (data, pilot, combined)
48 /// <tr> <td> L1Z <td> PRS + OS(data+pilot)
49 /// <tr> <td> E5a <td> L5I, L5Q, L5X <td> E5a (data, pilot, combined)
50 /// <tr> <td rowspan="3" valign="top"> E6 <td> L6A <td> E6 PRS signal
51 /// <tr> <td> L6B, L6C, L6X <td> E6 (data, pilot, combined)
52 /// <tr> <td> L6Z <td> E6 PRS + OS(data+pilot)
53 /// <tr> <td> E5b <td> L7I, L7Q, L7X <td> E5b (data, pilot, combined)
54 /// <tr> <td> E5 <td> L8I, L8Q, L8X <td> E5 AltBOC (data, pilot, combined)
55 /// <tr><td rowspan= "7" valign="top"> GLONASS <td rowspan="2" valign="top"> L1 <td> L1C <td> C/A-code
56 /// <tr> <td> L1P <td> P-code
57 /// <tr> <td rowspan="2" valign="top"> L2 <td> L2C <td> C/A-code
58 /// <tr> <td> L2P <td> P-code
59 /// <tr> <td> L3 <td> L3I, L3Q, L3X <td> L3 (data, pilot, combined)
60 /// <tr> <td> G1a <td> L4A, L4B, L4X <td> G1a (data, pilot, combined)
61 /// <tr> <td> G2b <td> L6A, L6B, L6X <td> G2a (data, pilot, combined)
62 /// <tr><td rowspan= "8" valign="top"> BeiDou (BDS-2/3) <td> B1 <td> L1D, L1P, L1X <td> B1 (data, pilot, combined)
63 /// <tr> <td> B1-2<td> L2I, L2Q, L2X <td> B1I(OS), B1Q, combined
64 /// <tr> <td> B2a <td> L5D, L5P, L5X <td> B2a (data, pilot, combined)
65 /// <tr> <td rowspan="2" valign="top"> B3 <td> L6I, L6Q, L6X <td> B3I, B3Q, combined
66 /// <tr> <td> L6A <td> B3A
67 /// <tr> <td rowspan="2" valign="top"> B2b <td> L7I, L7Q, L7X <td> BDS-2: B2I(OS), B2Q, combined
68 /// <tr> <td> L7D, L7P, L7Z <td> BDS-3: data, pilot, combined
69 /// <tr> <td> B2 <td> L8D, L8P, L8X <td> B2 (B2a+B2b): data, pilot, combined
70 /// <tr><td rowspan= "9" valign="top"> QZSS <td rowspan="3" valign="top"> L1 <td> L1C <td> C/A-code
71 /// <tr> <td> L1S, L1L, L1X <td> L1C (data, pilot, combined)
72 /// <tr> <td> L1Z <td> L1-SAIF signal
73 /// <tr> <td> L2 <td> L2S, L2L, L2X <td> L2C-code (medium, long, combined)
74 /// <tr> <td rowspan="2" valign="top"> L5 <td> L5I, L5Q, L5X <td> L5 (data, pilot, combined)
75 /// <tr> <td> L5D, L5P, L5Z <td> I, Q, combined
76 /// <tr> <td rowspan="3" valign="top"> L6 <td> L6S, L6L, L6X <td> LEX signal (short, long, combined)
77 /// <tr> <td> L6E <td> L6E
78 /// <tr> <td> L6Z <td> L6(D+E)
79 /// <tr><td rowspan= "4" valign="top"> IRNSS/NavIC <td rowspan="2" valign="top"> L5 <td> L5A <td> SPS Signal
80 /// <tr> <td> L5B, L5C, L5X <td> RS (data, pilot, combined)
81 /// <tr> <td rowspan="2" valign="top"> S <td> L9A <td> SPS signal
82 /// <tr> <td> L9B, L9C, L9X <td> RS (data, pilot, combined)
83 /// <tr><td rowspan= "2" valign="top"> SBAS <td> L1 <td> L1C <td> C/A-code
84 /// <tr> <td> L5 <td> L5I, L5Q, L5X <td> L5 (data, pilot, combined)
85 /// </table>
86 /// @note See \cite SpringerHandbookGNSS2017 Springer Handbook GNSS Annex A, Table A.5, p. 1211
87 /// @note See \cite RINEX-3.04 RINEX 3.04 Appendix A23, p. A43-A46 (97-100)
88 class Code
89 {
90 public:
91 /// @brief Enumeration of all Codes
92 enum Enum : uint8_t
93 {
94 None, ///< None
95
96 G1C, ///< GPS L1 - C/A-code
97 G1S, ///< GPS L1 - L1C-D (data)
98 G1L, ///< GPS L1 - L1C-P (pilot)
99 G1X, ///< GPS L1 - L1C-(D+P) (combined)
100 G1P, ///< GPS L1 - P-code (unencrypted)
101 G1W, ///< GPS L1 - Semicodeless P(Y) tracking (Z-tracking)
102 G1Y, ///< GPS L1 - Y-code (with decryption)
103 G1M, ///< GPS L1 - M-code
104 G1N, ///< GPS L1 - codeless
105 G2C, ///< GPS L2 - C/A-code
106 G2D, ///< GPS L2 - Semi-codeless P(Y) tracking (L1 C/A + (P2-P1))
107 G2S, ///< GPS L2 - L2C(M) (medium)
108 G2L, ///< GPS L2 - L2C(L) (long)
109 G2X, ///< GPS L2 - L2C(M+L) (combined)
110 G2P, ///< GPS L2 - P-code (unencrypted)
111 G2W, ///< GPS L2 - Semicodeless P(Y) tracking (Z-tracking)
112 G2Y, ///< GPS L2 - Y-code (with decryption)
113 G2M, ///< GPS L2 - M-code
114 G2N, ///< GPS L2 - codeless
115 G5I, ///< GPS L5 - Data
116 G5Q, ///< GPS L5 - Pilot
117 G5X, ///< GPS L5 - Combined
118
119 E1A, ///< GAL E1 - PRS signal
120 E1B, ///< GAL E1 - OS (data)
121 E1C, ///< GAL E1 - OS (pilot)
122 E1X, ///< GAL E1 - OS(B+C) (combined)
123 E1Z, ///< GAL E1 - PRS + OS (data + pilot)
124 E5I, ///< GAL E5a - Data
125 E5Q, ///< GAL E5a - Pilot
126 E5X, ///< GAL E5a - Combined
127 E6A, ///< GAL E6 - PRS signal
128 E6B, ///< GAL E6 - Data
129 E6C, ///< GAL E6 - Pilot
130 E6X, ///< GAL E6 - Combined (B+C)
131 E6Z, ///< GAL E6 - PRS + OS (A+B+C)
132 E7I, ///< GAL E5b - Data
133 E7Q, ///< GAL E5b - Pilot
134 E7X, ///< GAL E5b - Combined
135 E8I, ///< GAL E5(a+b) - AltBOC (data)
136 E8Q, ///< GAL E5(a+b) - AltBOC (pilot)
137 E8X, ///< GAL E5(a+b) - AltBOC (combined)
138
139 R1C, ///< GLO L1 - C/A-code
140 R1P, ///< GLO L1 - P-code
141 R2C, ///< GLO L2 - C/A-code
142 R2P, ///< GLO L2 - P-code
143 R3I, ///< GLO L3 - Data
144 R3Q, ///< GLO L3 - Pilot
145 R3X, ///< GLO L3 - Combined
146 R4A, ///< GLO G1a - L1OCd (data)
147 R4B, ///< GLO G1a - L1OCp (pilot)
148 R4X, ///< GLO G1a - L1OCd+L1OCp (combined)
149 R6A, ///< GLO G2a - L2CSI (data)
150 R6B, ///< GLO G2a - L2OCp (pilot)
151 R6X, ///< GLO G2a - L2CSI+L2OCp (combined)
152
153 B1D, ///< BeiDou B1 - Data (D)
154 B1P, ///< BeiDou B1 - Pilot(P)
155 B1X, ///< BeiDou B1 - D+P
156 B2I, ///< BeiDou B1-2 - B1I(OS)
157 B2Q, ///< BeiDou B1-2 - B1Q
158 B2X, ///< BeiDou B1-2 - B1I(OS), B1Q, combined
159 B5D, ///< BeiDou B2a - Data (D)
160 B5P, ///< BeiDou B2a - Pilot(P)
161 B5X, ///< BeiDou B2a - D+P
162 B6I, ///< BeiDou B3 - B3I
163 B6Q, ///< BeiDou B3 - B3Q
164 B6X, ///< BeiDou B3 - B3I, B3Q, combined
165 B6A, ///< BeiDou B3 - B3A
166 B7I, ///< BeiDou B2b (BDS-2) - B2I(OS)
167 B7Q, ///< BeiDou B2b (BDS-2) - B2Q
168 B7X, ///< BeiDou B2b (BDS-2) - B2I(OS), B2Q, combined
169 B7D, ///< BeiDou B2b (BDS-3) - Data (D)
170 B7P, ///< BeiDou B2b (BDS-3) - Pilot(P)
171 B7Z, ///< BeiDou B2b (BDS-3) - D+P
172 B8D, ///< BeiDou B2 (B2a+B2b) - Data (D)
173 B8P, ///< BeiDou B2 (B2a+B2b) - Pilot(P)
174 B8X, ///< BeiDou B2 (B2a+B2b) - D+P
175
176 J1C, ///< QZSS L1 - C/A-code
177 J1S, ///< QZSS L1 - L1C (data)
178 J1L, ///< QZSS L1 - L1C (pilot)
179 J1X, ///< QZSS L1 - L1C (combined)
180 J1Z, ///< QZSS L1 - L1-SAIF signal
181 J2S, ///< QZSS L2 - L2C-code (medium)
182 J2L, ///< QZSS L2 - L2C-code (long)
183 J2X, ///< QZSS L2 - L2C-code (combined)
184 J5I, ///< QZSS L5 - Data
185 J5Q, ///< QZSS L5 - Pilot
186 J5X, ///< QZSS L5 - Combined
187 J5D, ///< QZSS L5S - I
188 J5P, ///< QZSS L5S - Q
189 J5Z, ///< QZSS L5S - I+Q
190 J6S, ///< QZSS L6 - L6D LEX signal (short)
191 J6L, ///< QZSS L6 - L6P LEX signal (long)
192 J6X, ///< QZSS L6 - L6(D+P) LEX signal (combined)
193 J6E, ///< QZSS L6 - L6E
194 J6Z, ///< QZSS L6 - L6(D+E)
195
196 I5A, ///< IRNSS L5 - SPS Signal
197 I5B, ///< IRNSS L5 - RS (data)
198 I5C, ///< IRNSS L5 - RS (pilot)
199 I5X, ///< IRNSS L5 - RS (combined)
200 I9A, ///< IRNSS S - SPS signal
201 I9B, ///< IRNSS S - RS (data)
202 I9C, ///< IRNSS S - RS (pilot)
203 I9X, ///< IRNSS S - RS (combined)
204
205 S1C, ///< SBAS L1 - C/A-code
206 S5I, ///< SBAS L5 - Data
207 S5Q, ///< SBAS L5 - Pilot
208 S5X, ///< SBAS L5 - Combined
209 };
210 /// @brief Helper variables
211 enum : uint8_t
212 {
213 _GPS_START = G1C, ///< GPS start index in the Enum
214 _GPS_END = G5X, ///< GPS end index in the Enum
215 _GAL_START = E1A, ///< GAL start index in the Enum
216 _GAL_END = E8X, ///< GAL end index in the Enum
217 _GLO_START = R1C, ///< GLO start index in the Enum
218 _GLO_END = R6X, ///< GLO end index in the Enum
219 _BDS_START = B1D, ///< BDS start index in the Enum
220 _BDS_END = B8X, ///< BDS end index in the Enum
221 _QZSS_START = J1C, ///< QZSS start index in the Enum
222 _QZSS_END = J6Z, ///< QZSS end index in the Enum
223 _IRNSS_START = I5A, ///< IRNSS start index in the Enum
224 _IRNSS_END = I9X, ///< IRNSS end index in the Enum
225 _SBAS_START = S1C, ///< SBAS start index in the Enum
226 _SBAS_END = S5X, ///< SBAS end index in the Enum
227
228 _G01_START = G1C, ///< GPS L1 start index in the Enum
229 _G01_END = G1N, ///< GPS L1 end index in the Enum
230 _G02_START = G2C, ///< GPS L2 start index in the Enum
231 _G02_END = G2N, ///< GPS L2 end index in the Enum
232 _G05_START = G5I, ///< GPS L5 start index in the Enum
233 _G05_END = G5X, ///< GPS L5 end index in the Enum
234
235 _E01_START = E1A, ///< GAL E1 start index in the Enum
236 _E01_END = E1Z, ///< GAL E1 end index in the Enum
237 _E05_START = E5I, ///< GAL E5a start index in the Enum
238 _E05_END = E5X, ///< GAL E5a end index in the Enum
239 _E06_START = E6B, ///< GAL E6 start index in the Enum
240 _E06_END = E6X, ///< GAL E6 end index in the Enum
241 _E07_START = E7I, ///< GAL E5b start index in the Enum
242 _E07_END = E7X, ///< GAL E5b end index in the Enum
243 _E08_START = E8I, ///< GAL E5(a+b) start index in the Enum
244 _E08_END = E8X, ///< GAL E5(a+b) end index in the Enum
245
246 _R01_START = R1C, ///< GLO L1 start index in the Enum
247 _R01_END = R1P, ///< GLO L1 end index in the Enum
248 _R02_START = R2C, ///< GLO L2 start index in the Enum
249 _R02_END = R2P, ///< GLO L2 end index in the Enum
250 _R03_START = R3I, ///< GLO L3 start index in the Enum
251 _R03_END = R3X, ///< GLO L3 end index in the Enum
252 _R04_START = R4A, ///< GLO G1a start index in the Enum
253 _R04_END = R4X, ///< GLO G1a end index in the Enum
254 _R06_START = R6A, ///< GLO G2a start index in the Enum
255 _R06_END = R6X, ///< GLO G2a end index in the Enum
256
257 _B01_START = B1D, ///< BDS B1 start index in the Enum
258 _B01_END = B1X, ///< BDS B1 end index in the Enum
259 _B02_START = B2I, ///< BDS B1-2 start index in the Enum
260 _B02_END = B2X, ///< BDS B1-2 end index in the Enum
261 _B05_START = B5D, ///< BDS B2a start index in the Enum
262 _B05_END = B5X, ///< BDS B2a end index in the Enum
263 _B06_START = B6I, ///< BDS B3 start index in the Enum
264 _B06_END = B6A, ///< BDS B3 end index in the Enum
265 _B07_START = B7I, ///< BDS B2b start index in the Enum
266 _B07_END = B7Z, ///< BDS B2b end index in the Enum
267 _B08_START = B8D, ///< BDS B2 (B2a+B2b) start index in the Enum
268 _B08_END = B8X, ///< BDS B2 (B2a+B2b) end index in the Enum
269
270 _J01_START = J1C, ///< QZSS L1 start index in the Enum
271 _J01_END = J1Z, ///< QZSS L1 end index in the Enum
272 _J02_START = J2S, ///< QZSS L2 start index in the Enum
273 _J02_END = J2X, ///< QZSS L2 end index in the Enum
274 _J05_START = J5I, ///< QZSS L5 start index in the Enum
275 _J05_END = J5Z, ///< QZSS L5 end index in the Enum
276 _J06_START = J6S, ///< QZSS L6 start index in the Enum
277 _J06_END = J6Z, ///< QZSS L6 end index in the Enum
278
279 _I05_START = I5A, ///< IRNSS L5 start index in the Enum
280 _I05_END = I5X, ///< IRNSS L5 end index in the Enum
281 _I09_START = I9A, ///< IRNSS S start index in the Enum
282 _I09_END = I9X, ///< IRNSS S end index in the Enum
283
284 _S01_START = S1C, ///< SBAS L start index in the Enum
285 _S01_END = S1C, ///< SBAS L end index in the Enum
286 _S05_START = S5I, ///< SBAS L start index in the Enum
287 _S05_END = S5X, ///< SBAS L end index in the Enum
288
289 COUNT = S5X + 1 ///< Amount of Codes in the Enum
290 };
291
292 /// Typedef for the bitset with size of COUNT
293 using Set = std::bitset<COUNT>;
294
295 /// Default constructor for an empty code
296 564800 constexpr Code() = default;
297
298 /// @brief Constructor from a biset
299 /// @param[in] set Bitset with values to construct the Code from
300 59684969 constexpr explicit Code(const Set& set) : value(set) {}
301
302 /// @brief Constructor from a satellite system
303 /// @param[in] sys System to set all codes for
304 explicit Code(SatelliteSystem_ sys);
305
306 /// @brief Constructor from a frequency
307 /// @param[in] freq Frequency to set all codes for
308 explicit Code(Frequency_ freq);
309
310 /// @brief Constructor from a single code value
311 /// @param[in] e Code enum value to construct the code from
312 307123095 Code(Enum e) { value.set(e, true); } // NOLINT(hicpp-explicit-conversions, google-explicit-constructor)
313
314 /// Implicit bool conversion operator. Allows if(...)
315 58831749 explicit operator bool() const { return value.any(); }
316
317 /// @brief std::bitset conversion operator
318 /// @return The bitset representation of the type
319 71192 constexpr explicit operator Set() const { return value; }
320
321 /// @brief std::string conversion operator
322 /// @return A std::string representation of the type
323 explicit operator std::string() const;
324
325 /// @brief Generates a Code from frequency and attribute
326 /// @param[in] freq Frequency of the code
327 /// @param[in] attribute Attribute letter of the code
328 /// @return Code representation
329 static Code fromFreqAttr(Frequency freq, char attribute);
330
331 /// @brief Returns a short description for the code
332 /// @param[in] code GNSS signal code
333 static const char* GetCodeDescription(Code code);
334
335 /// @brief Returns a short description for the code
336 [[nodiscard]] const char* getDescription() const;
337
338 /// @brief Returns the frequency for the code
339 /// @param[in] code GNSS signal code
340 static Frequency GetCodeFequency(Code code);
341
342 /// @brief Returns the frequency for the code
343 [[nodiscard]] Frequency getFrequency() const;
344
345 /// @brief Checks if the codes are part of a combined code
346 /// @param[in] first First GNSS signal code
347 /// @param[in] second Second GNSS signal code
348 static bool IsCodeCombined(Code first, Code second);
349
350 /// @brief Returns a list with all possible codes
351 static std::vector<Code> GetAll();
352
353 /// @brief Returns the enum value for the code (only one must be set)
354 /// @param code GNSS signal code
355 static Enum GetCodeEnumValue(Code code);
356
357 /// @brief Returns the enum value for the code (only one must be set)
358 [[nodiscard]] Enum getEnumValue() const;
359
360 // #####################################################################################################################################
361
362 /// @brief Allows combining flags of the Code enum.
363 /// @param[in] lhs Left-hand side value.
364 /// @param[in] rhs Right-hand side value.
365 /// @return The binary ORed value.
366 friend Code operator|(const Code& lhs, const Code& rhs);
367 /// @brief Allows combining flags of the Code enum.
368 /// @param[in] lhs Left-hand side value.
369 /// @param[in] rhs Right-hand side value.
370 /// @return The binary ORed value.
371 friend Code operator|(const Code& lhs, const Enum& rhs);
372 /// @brief Allows combining flags of the Code enum.
373 /// @param[in] lhs Left-hand side value.
374 /// @param[in] rhs Right-hand side value.
375 /// @return The binary ORed value.
376 friend Code operator|(const Enum& lhs, const Code& rhs);
377
378 /// @brief Allows combining flags of the Code enum.
379 /// @param[in] rhs Right-hand side value.
380 /// @return The binary ORed value.
381 Code& operator|=(const Code& rhs);
382 /// @brief Allows combining flags of the Code enum.
383 /// @param[in] rhs Right-hand side value.
384 /// @return The binary ORed value.
385 Code& operator|=(const Enum& rhs);
386
387 /// @brief Allows combining flags of the Code enum.
388 /// @param[in] lhs Left-hand side value.
389 /// @param[in] rhs Right-hand side value.
390 /// @return The binary ANDed value.
391 friend Code operator&(const Code& lhs, const Code& rhs);
392 /// @brief Allows combining flags of the Code enum.
393 /// @param[in] lhs Left-hand side value.
394 /// @param[in] rhs Right-hand side value.
395 /// @return The binary ANDed value.
396 friend Code operator&(const Code& lhs, const Enum& rhs);
397 /// @brief Allows combining flags of the Code enum.
398 /// @param[in] lhs Left-hand side value.
399 /// @param[in] rhs Right-hand side value.
400 /// @return The binary ANDed value.
401 friend Code operator&(const Enum& lhs, const Code& rhs);
402
403 /// @brief Allows combining flags of the Code enum.
404 /// @param[in] rhs Right-hand side value.
405 /// @return The binary ANDed value.
406 Code& operator&=(const Code& rhs);
407 /// @brief Allows combining flags of the Code enum.
408 /// @param[in] rhs Right-hand side value.
409 /// @return The binary ANDed value.
410 Code& operator&=(const Enum& rhs);
411
412 /// @brief Allows negating flags of the Code enum.
413 Code operator~() const;
414
415 // #####################################################################################################################################
416
417 /// @brief Equal compares values
418 /// @param[in] lhs Left-hand side of the operator
419 /// @param[in] rhs Right-hand side of the operator
420 /// @return Whether the comparison was successful
421 friend bool operator==(const Code& lhs, const Code& rhs);
422
423 /// @brief Equal compares values
424 /// @param[in] lhs Left-hand side of the operator
425 /// @param[in] rhs Right-hand side of the operator
426 /// @return Whether the comparison was successful
427 friend bool operator==(const Code& lhs, const Enum& rhs);
428
429 /// @brief Equal compares values
430 /// @param[in] lhs Left-hand side of the operator
431 /// @param[in] rhs Right-hand side of the operator
432 /// @return Whether the comparison was successful
433 friend bool operator==(const Enum& lhs, const Code& rhs);
434
435 /// @brief Inequal compares values
436 /// @param[in] lhs Left-hand side of the operator
437 /// @param[in] rhs Right-hand side of the operator
438 /// @return Whether the comparison was successful
439 friend bool operator!=(const Code& lhs, const Code& rhs);
440 /// @brief Inequal compares values
441 /// @param[in] lhs Left-hand side of the operator
442 /// @param[in] rhs Right-hand side of the operator
443 /// @return Whether the comparison was successful
444 friend bool operator!=(const Code& lhs, const Enum& rhs);
445 /// @brief Inequal compares values
446 /// @param[in] lhs Left-hand side of the operator
447 /// @param[in] rhs Right-hand side of the operator
448 /// @return Whether the comparison was successful
449 friend bool operator!=(const Enum& lhs, const Code& rhs);
450
451 /// @brief Less than comparison
452 /// @param[in] lhs Left-hand side of the operator
453 /// @param[in] rhs Right hand side of the operator
454 /// @return True if lhs < rhs
455 friend bool operator<(const Code& lhs, const Code& rhs);
456
457 /// @brief Less than comparison
458 /// @param[in] lhs Left-hand side of the operator
459 /// @param[in] rhs Right hand side of the operator
460 /// @return True if lhs < rhs
461 friend bool operator<(const Code& lhs, const Enum& rhs);
462
463 /// @brief Less than comparison
464 /// @param[in] lhs Left-hand side of the operator
465 /// @param[in] rhs Right hand side of the operator
466 /// @return True if lhs < rhs
467 friend bool operator<(const Enum& lhs, const Code& rhs);
468
469 // #####################################################################################################################################
470
471 /// @brief Allows filtering Code with SatelliteSystem.
472 /// @param[in] lhs Left-hand side enum value.
473 /// @param[in] rhs Right-hand side enum value.
474 /// @return The binary ANDed value.
475 friend Code operator&(Code lhs, SatelliteSystem_ rhs);
476 /// @brief Allows filtering Code with SatelliteSystem.
477 /// @param[in] lhs Left-hand side enum value.
478 /// @param[in] rhs Right-hand side enum value.
479 /// @return The binary ANDed value.
480 friend Code operator&(SatelliteSystem_ lhs, Code rhs);
481 /// @brief Allows filtering Code with SatelliteSystem.
482 /// @param[in] rhs Right-hand side enum value.
483 /// @return The binary ANDed value.
484 Code& operator&=(const SatelliteSystem_& rhs);
485 /// @brief Allows filtering Code with SatelliteSystem.
486 /// @param[in] lhs Left-hand side enum value.
487 /// @param[in] rhs Right-hand side enum value.
488 /// @return The binary ANDed value.
489 friend Code operator&(Code lhs, SatelliteSystem rhs);
490 /// @brief Allows filtering Code with SatelliteSystem.
491 /// @param[in] lhs Left-hand side enum value.
492 /// @param[in] rhs Right-hand side enum value.
493 /// @return The binary ANDed value.
494 friend Code operator&(SatelliteSystem lhs, Code rhs);
495 /// @brief Allows filtering Code with SatelliteSystem.
496 /// @param[in] rhs Right-hand side enum value.
497 /// @return The binary ANDed value.
498 Code& operator&=(const SatelliteSystem& rhs);
499
500 /// @brief Allows filtering Code with SatelliteSystem.
501 /// @param[in] lhs Left-hand side enum value.
502 /// @param[in] rhs Right-hand side enum value.
503 /// @return The binary ORed value.
504 friend Code operator|(Code lhs, SatelliteSystem_ rhs);
505 /// @brief Allows filtering Code with SatelliteSystem.
506 /// @param[in] lhs Left-hand side enum value.
507 /// @param[in] rhs Right-hand side enum value.
508 /// @return The binary ORed value.
509 friend Code operator|(SatelliteSystem_ lhs, Code rhs);
510 /// @brief Allows filtering Code with SatelliteSystem.
511 /// @param[in] rhs Right-hand side enum value.
512 /// @return The binary ORed value.
513 Code& operator|=(const SatelliteSystem_& rhs);
514 /// @brief Allows filtering Code with SatelliteSystem.
515 /// @param[in] lhs Left-hand side enum value.
516 /// @param[in] rhs Right-hand side enum value.
517 /// @return The binary ORed value.
518 friend Code operator|(Code lhs, SatelliteSystem rhs);
519 /// @brief Allows filtering Code with SatelliteSystem.
520 /// @param[in] lhs Left-hand side enum value.
521 /// @param[in] rhs Right-hand side enum value.
522 /// @return The binary ORed value.
523 friend Code operator|(SatelliteSystem lhs, Code rhs);
524 /// @brief Allows filtering Code with SatelliteSystem.
525 /// @param[in] rhs Right-hand side enum value.
526 /// @return The binary ORed value.
527 Code& operator|=(const SatelliteSystem& rhs);
528
529 // #####################################################################################################################################
530
531 /// @brief Allows filtering Code with Frequency.
532 /// @param[in] lhs Left-hand side enum value.
533 /// @param[in] rhs Right-hand side enum value.
534 /// @return The binary ANDed value.
535 friend Code operator&(Code lhs, Frequency_ rhs);
536 /// @brief Allows filtering Code with Frequency.
537 /// @param[in] lhs Left-hand side enum value.
538 /// @param[in] rhs Right-hand side enum value.
539 /// @return The binary ANDed value.
540 friend Code operator&(Frequency_ lhs, Code rhs);
541 /// @brief Allows filtering Code with Frequency.
542 /// @param[in] rhs Right-hand side enum value.
543 /// @return The binary ANDed value.
544 Code& operator&=(const Frequency_& rhs);
545 /// @brief Allows filtering Code with Frequency.
546 /// @param[in] lhs Left-hand side enum value.
547 /// @param[in] rhs Right-hand side enum value.
548 /// @return The binary ANDed value.
549 friend Code operator&(Code lhs, Frequency rhs);
550 /// @brief Allows filtering Code with Frequency.
551 /// @param[in] lhs Left-hand side enum value.
552 /// @param[in] rhs Right-hand side enum value.
553 /// @return The binary ANDed value.
554 friend Code operator&(Frequency lhs, Code rhs);
555 /// @brief Allows filtering Code with Frequency.
556 /// @param[in] rhs Right-hand side enum value.
557 /// @return The binary ANDed value.
558 Code& operator&=(const Frequency& rhs);
559
560 /// @brief Allows filtering Code with Frequency.
561 /// @param[in] lhs Left-hand side enum value.
562 /// @param[in] rhs Right-hand side enum value.
563 /// @return The binary ORed value.
564 friend Code operator|(Code lhs, Frequency_ rhs);
565 /// @brief Allows filtering Code with Frequency.
566 /// @param[in] lhs Left-hand side enum value.
567 /// @param[in] rhs Right-hand side enum value.
568 /// @return The binary ORed value.
569 friend Code operator|(Frequency_ lhs, Code rhs);
570 /// @brief Allows filtering Code with Frequency.
571 /// @param[in] rhs Right-hand side enum value.
572 /// @return The binary ORed value.
573 Code& operator|=(const Frequency_& rhs);
574 /// @brief Allows filtering Code with Frequency.
575 /// @param[in] lhs Left-hand side enum value.
576 /// @param[in] rhs Right-hand side enum value.
577 /// @return The binary ORed value.
578 friend Code operator|(Code lhs, Frequency rhs);
579 /// @brief Allows filtering Code with Frequency.
580 /// @param[in] lhs Left-hand side enum value.
581 /// @param[in] rhs Right-hand side enum value.
582 /// @return The binary ORed value.
583 friend Code operator|(Frequency lhs, Code rhs);
584 /// @brief Allows filtering Code with Frequency.
585 /// @param[in] rhs Right-hand side enum value.
586 /// @return The binary ORed value.
587 Code& operator|=(const Frequency& rhs);
588
589 // #####################################################################################################################################
590
591 private:
592 /// Code bitset
593 Set value;
594 };
595
596 // #########################################################################################################################################
597
598 /// @brief Converts the provided link into a json object
599 /// @param[out] j Json object which gets filled with the info
600 /// @param[in] data Data to convert into json
601 void to_json(json& j, const Code& data);
602 /// @brief Converts the provided json object into a link object
603 /// @param[in] j Json object with the needed values
604 /// @param[out] data Object to fill from the json
605 void from_json(const json& j, Code& data);
606
607 // #########################################################################################################################################
608
609 /// @brief Allows combining flags of the Code enum.
610 /// @param[in] lhs Left-hand side value.
611 /// @param[in] rhs Right-hand side value.
612 /// @return The binary ORed value.
613 Code operator|(const Code::Enum& lhs, const Code::Enum& rhs);
614 /// @brief Allows combining flags of the Code enum.
615 /// @param[in] lhs Left-hand side value.
616 /// @param[in] rhs Right-hand side value.
617 /// @return The binary ANDed value.
618 Code operator&(const Code::Enum& lhs, const Code::Enum& rhs);
619
620 const Code Code_G1S_G1L_G1X = Code::G1S | Code::G1L | Code::G1X; ///< L1C (data, pilot, combined)
621 const Code Code_G2S_G2L_G2X = Code::G2S | Code::G2L | Code::G2X; ///< L2C-code (medium, long, combined)
622 const Code Code_G5I_G5Q_G5X = Code::G5I | Code::G5Q | Code::G5X; ///< L5 (data, pilot, combined)
623
624 const Code Code_E1B_E1C_E1X = Code::E1B | Code::E1C | Code::E1X; ///< OS (data, pilot, combined)
625 const Code Code_E5I_E5Q_E5X = Code::E5I | Code::E5Q | Code::E5X; ///< E5a (data, pilot, combined)
626 const Code Code_E6B_E6C_E6X = Code::E6B | Code::E6C | Code::E6X; ///< E6 (data, pilot, combined)
627 const Code Code_E7I_E7Q_E7X = Code::E7I | Code::E7Q | Code::E7X; ///< E5b (data, pilot, combined)
628 const Code Code_E8I_E8Q_E8X = Code::E8I | Code::E8Q | Code::E8X; ///< E5 AltBOC (data, pilot, combined)
629
630 const Code Code_R3I_R3Q_R3X = Code::R3I | Code::R3Q | Code::R3X; ///< L3 (data, pilot, combined)
631 const Code Code_R4A_R4B_R4X = Code::R4A | Code::R4B | Code::R4X; ///< G1a (data, pilot, combined)
632 const Code Code_R6A_R6B_R6X = Code::R6A | Code::R6B | Code::R6X; ///< G2a (data, pilot, combined)
633
634 const Code Code_B1D_B1P_B1X = Code::B1D | Code::B1P | Code::B1X; ///< B1 (data, pilot, combined)
635 const Code Code_B2I_B2Q_B2X = Code::B2I | Code::B2Q | Code::B2X; ///< B1I(OS), B1Q, combined
636 const Code Code_B5D_B5P_B5X = Code::B5D | Code::B5P | Code::B5X; ///< B2a (data, pilot, combined)
637 const Code Code_B6I_B6Q_B6X = Code::B6I | Code::B6Q | Code::B6X; ///< B3I, B3Q, combined
638 const Code Code_B7I_B7Q_B7X = Code::B7I | Code::B7Q | Code::B7X; ///< B2I(OS), B2Q, combined
639 const Code Code_B7D_B7P_B7Z = Code::B7D | Code::B7P | Code::B7Z; ///< B2b (data, pilot, combined)
640 const Code Code_B8D_B8P_B8X = Code::B8D | Code::B8P | Code::B8X; ///< B2 (B2a+B2b) (data, pilot, combined)
641
642 const Code Code_J1S_J1L_J1X = Code::J1S | Code::J1L | Code::J1X; ///< L1C (data, pilot, combined)
643 const Code Code_J2S_J2L_J2X = Code::J2S | Code::J2L | Code::J2X; ///< L2C-code (medium, long, combined)
644 const Code Code_J5I_J5Q_J5X = Code::J5I | Code::J5Q | Code::J5X; ///< L5 (data, pilot, combined)
645 const Code Code_J5D_J5P_J5Z = Code::J5D | Code::J5P | Code::J5Z; ///< L5 (data, pilot, combined)
646 const Code Code_J6S_J6L_J6X = Code::J6S | Code::J6L | Code::J6X; ///< LEX signal (short, long, combined)
647
648 const Code Code_I5B_I5C_I5X = Code::I5B | Code::I5C | Code::I5X; ///< RS (data, pilot, combined)
649 const Code Code_I9B_I9C_I9X = Code::I9B | Code::I9C | Code::I9X; ///< RS (data, pilot, combined)
650
651 const Code Code_S5I_S5Q_S5X = Code::S5I | Code::S5Q | Code::S5X; ///< L5 (data, pilot, combined)
652
653 const Code Code_ALL = Code(Code::Set().set()); ///< All codes set
654 /// Default selection for codes
655 const Code Code_Default = Code(Code::Set().set())
656 & ~Code(Code::G1Y) // GPS L1 - Y-code (with decryption)
657 & ~Code(Code::G1M) // GPS L1 - M-code
658 & ~Code(Code::G2Y) // GPS L2 - Y-code (with decryption)
659 & ~Code(Code::G2M); // GPS L2 - M-code
660
661 /// @brief Shows a ComboBox to select signal codes
662 /// @param[in] label Label to show beside the combo box. This has to be a unique id for ImGui.
663 /// @param[in, out] code Reference to the code object to select
664 /// @param[in] filterFreq Frequencies to select codes for. Other Frequencies will be disabled.
665 /// @param[in] singleSelect If true, only one code can be selected at a time
666 bool ShowCodeSelector(const char* label, Code& code, const Frequency& filterFreq, bool singleSelect = false);
667
668 } // namespace NAV
669
670 /// @brief Stream insertion operator overload
671 /// @param[in, out] os Output stream object to stream the time into
672 /// @param[in] obj Object to print
673 /// @return Returns the output stream object in order to chain stream insertions
674 std::ostream& operator<<(std::ostream& os, const NAV::Code& obj);
675
676 namespace std
677 {
678
679 /// @brief Hash function for Frequency (needed for unordered_map)
680 template<>
681 struct hash<NAV::Code>
682 {
683 /// @brief Hash function for signal code
684 /// @param[in] c Signal code
685 /// @return Has value for the signal code
686 1129600 std::size_t operator()(const NAV::Code& c) const
687 {
688 1129600 return static_cast<size_t>(c.getEnumValue());
689 }
690 };
691 } // namespace std
692
693 #ifndef DOXYGEN_IGNORE
694
695 /// @brief Formatter for Code
696 template<>
697 struct fmt::formatter<NAV::Code> : fmt::formatter<std::string>
698 {
699 /// @brief Defines how to format Code structs
700 /// @param[in] code Struct to format
701 /// @param[in, out] ctx Format context
702 /// @return Output iterator
703 template<typename FormatContext>
704 549395 auto format(const NAV::Code& code, FormatContext& ctx) const
705 {
706
1/2
✓ Branch 1 taken 549448 times.
✗ Branch 2 not taken.
1098815 return fmt::formatter<std::string>::format(std::string(code), ctx);
707 }
708 };
709
710 #endif
711