Branch data Line data Source code
1 : : /* 2 : : * ----------------- BEGIN LICENSE BLOCK --------------------------------- 3 : : * 4 : : * Copyright (C) 2018-2020 Intel Corporation 5 : : * 6 : : * SPDX-License-Identifier: MIT 7 : : * 8 : : * ----------------- END LICENSE BLOCK ----------------------------------- 9 : : */ 10 : : 11 : : /** 12 : : * Generated file 13 : : * @file 14 : : * 15 : : * Generator Version : 11.0.0-1997 16 : : */ 17 : : 18 : : #pragma once 19 : : 20 : : #include <cmath> 21 : : #include <iostream> 22 : : #include <limits> 23 : : #include <sstream> 24 : : #include <stdexcept> 25 : : #include "spdlog/fmt/ostr.h" 26 : : #include "spdlog/spdlog.h" 27 : : /*! 28 : : * @brief namespace ad 29 : : */ 30 : : namespace ad { 31 : : /*! 32 : : * @brief namespace map 33 : : */ 34 : : namespace map { 35 : : /*! 36 : : * @brief namespace point 37 : : * 38 : : * Handling geographic positions in different coordinate systems 39 : : */ 40 : : namespace point { 41 : : 42 : : /*! 43 : : * \brief Define to indicate whether throwing exceptions is enabled 44 : : */ 45 : : #define AD_MAP_POINT_ENUHEADING_THROWS_EXCEPTION 1 46 : : 47 : : #if SAFE_DATATYPES_EXPLICIT_CONVERSION 48 : : /*! 49 : : * \brief Enable/Disable explicit conversion. Currently set to "only explicit conversion". 50 : : */ 51 : : #define _AD_MAP_POINT_ENUHEADING_EXPLICIT_CONVERSION_ explicit 52 : : #else 53 : : /*! 54 : : * \brief Enable/Disable explicit conversion. Currently set to "implicit conversion allowed". 55 : : */ 56 : : #define _AD_MAP_POINT_ENUHEADING_EXPLICIT_CONVERSION_ 57 : : #endif 58 : : 59 : : /*! 60 : : * \brief DataType ENUHeading 61 : : * 62 : : * Angle in ENU coordinate system as angle measured from East to North axis (yaw) in radians. 63 : : * The unit is: Radian 64 : : */ 65 : : class ENUHeading 66 : : { 67 : : public: 68 : : /*! 69 : : * \brief constant defining the minimum valid ENUHeading value (used in isValid()) 70 : : */ 71 : : static const double cMinValue; 72 : : 73 : : /*! 74 : : * \brief constant defining the maximum valid ENUHeading value (used in isValid()) 75 : : */ 76 : : static const double cMaxValue; 77 : : 78 : : /*! 79 : : * \brief constant defining the assumed ENUHeading value accuracy 80 : : * (used in comparison operator==(), operator!=()) 81 : : */ 82 : : static const double cPrecisionValue; 83 : : 84 : : /*! 85 : : * \brief default constructor 86 : : * 87 : : * The default value of ENUHeading is: 88 : : * std::numeric_limits<double>::quiet_NaN() 89 : : */ 90 : 1214 : ENUHeading() 91 : 1214 : : mENUHeading(std::numeric_limits<double>::quiet_NaN()) 92 : : { 93 : 1214 : } 94 : : 95 : : /*! 96 : : * \brief standard constructor 97 : : * 98 : : * \note \ref \_AD_MAP_POINT_ENUHEADING_EXPLICIT_CONVERSION\_ defines, if only an explicit conversion is allowed. 99 : : */ 100 : 8854 : _AD_MAP_POINT_ENUHEADING_EXPLICIT_CONVERSION_ ENUHeading(double const iENUHeading) 101 : 8854 : : mENUHeading(iENUHeading) 102 : : { 103 : 8854 : } 104 : : 105 : : /*! 106 : : * \brief standard copy constructor 107 : : */ 108 : : ENUHeading(const ENUHeading &other) = default; 109 : : 110 : : /*! 111 : : * \brief standard move constructor 112 : : */ 113 : : ENUHeading(ENUHeading &&other) = default; 114 : : 115 : : /** 116 : : * \brief standard assignment operator 117 : : * 118 : : * \param[in] other Other ENUHeading 119 : : * 120 : : * \returns Reference to this ENUHeading. 121 : : */ 122 : : ENUHeading &operator=(const ENUHeading &other) = default; 123 : : 124 : : /** 125 : : * \brief standard move operator 126 : : * 127 : : * \param[in] other Other ENUHeading 128 : : * 129 : : * \returns Reference to this ENUHeading. 130 : : */ 131 : : ENUHeading &operator=(ENUHeading &&other) = default; 132 : : 133 : : /** 134 : : * \brief standard comparison operator 135 : : * 136 : : * \param[in] other Other ENUHeading 137 : : * 138 : : * \returns \c true if both ENUHeading are valid and can be taken as numerically equal 139 : : */ 140 : 2708 : bool operator==(const ENUHeading &other) const 141 : : { 142 : 2708 : ensureValid(); 143 : 2706 : other.ensureValid(); 144 : 2704 : return std::fabs(mENUHeading - other.mENUHeading) < cPrecisionValue; 145 : : } 146 : : 147 : : /** 148 : : * \brief standard comparison operator 149 : : * 150 : : * \param[in] other Other ENUHeading. 151 : : * 152 : : * \returns \c true if one of the ENUHeading is not valid or they can be taken as numerically different 153 : : */ 154 : 1440 : bool operator!=(const ENUHeading &other) const 155 : : { 156 : 1440 : return !operator==(other); 157 : : } 158 : : 159 : : /** 160 : : * \brief standard comparison operator 161 : : * 162 : : * \param[in] other Other ENUHeading. 163 : : * 164 : : * \returns \c true if both ENUHeading are valid and 165 : : * this ENUHeading is strictly numerically greater than other. 166 : : * \note the precision of ENUHeading is considered 167 : : */ 168 : 2274 : bool operator>(const ENUHeading &other) const 169 : : { 170 : 2274 : ensureValid(); 171 : 2273 : other.ensureValid(); 172 [ + + + + ]: 2272 : return (mENUHeading > other.mENUHeading) && operator!=(other); 173 : : } 174 : : 175 : : /** 176 : : * \brief standard comparison operator 177 : : * 178 : : * \param[in] other Other ENUHeading. 179 : : * 180 : : * \returns \c true if both ENUHeading are valid and 181 : : * this ENUHeading is strictly numerically smaller than other. 182 : : * \note the precision of ENUHeading is considered 183 : : */ 184 : 1826 : bool operator<(const ENUHeading &other) const 185 : : { 186 : 1826 : ensureValid(); 187 : 1825 : other.ensureValid(); 188 [ + + + + ]: 1824 : return (mENUHeading < other.mENUHeading) && operator!=(other); 189 : : } 190 : : 191 : : /** 192 : : * \brief standard comparison operator 193 : : * 194 : : * \param[in] other Other ENUHeading. 195 : : * 196 : : * \returns \c true if both ENUHeading are valid and 197 : : * this ENUHeading is numerically greater than other. 198 : : * \note the precision of ENUHeading is considered 199 : : */ 200 : 7 : bool operator>=(const ENUHeading &other) const 201 : : { 202 : 7 : ensureValid(); 203 : 6 : other.ensureValid(); 204 [ + + + + ]: 5 : return ((mENUHeading > other.mENUHeading) || operator==(other)); 205 : : } 206 : : 207 : : /** 208 : : * \brief standard comparison operator 209 : : * 210 : : * \param[in] other Other ENUHeading 211 : : * 212 : : * \returns \c true if both ENUHeading are valid and 213 : : * this ENUHeading is numerically smaller than other. 214 : : * \note the precision of ENUHeading is considered 215 : : */ 216 : 92 : bool operator<=(const ENUHeading &other) const 217 : : { 218 : 92 : ensureValid(); 219 : 91 : other.ensureValid(); 220 [ + + + + ]: 90 : return ((mENUHeading < other.mENUHeading) || operator==(other)); 221 : : } 222 : : 223 : : /** 224 : : * \brief standard arithmetic operator 225 : : * 226 : : * \param[in] other Other ENUHeading 227 : : * 228 : : * \returns Result of arithmetic operation. 229 : : * 230 : : * \note throws a std::out_of_range exception if one of the two operands or the result of 231 : : * the operation is not valid 232 : : */ 233 : 115 : ENUHeading operator+(const ENUHeading &other) const 234 : : { 235 [ + + ]: 115 : ensureValid(); 236 [ + + ]: 114 : other.ensureValid(); 237 : 113 : ENUHeading const result(mENUHeading + other.mENUHeading); 238 [ + + ]: 113 : result.ensureValid(); 239 : 112 : return result; 240 : : } 241 : : 242 : : /** 243 : : * \brief standard arithmetic operator 244 : : * 245 : : * \param[in] other Other ENUHeading 246 : : * 247 : : * \returns Result of arithmetic operation. 248 : : * 249 : : * \note throws a std::out_of_range exception if one of the two operands or the result of 250 : : * the operation is not valid 251 : : */ 252 : 482 : ENUHeading &operator+=(const ENUHeading &other) 253 : : { 254 : 482 : ensureValid(); 255 : 481 : other.ensureValid(); 256 : 480 : mENUHeading += other.mENUHeading; 257 : 480 : ensureValid(); 258 : 479 : return *this; 259 : : } 260 : : 261 : : /** 262 : : * \brief standard arithmetic operator 263 : : * 264 : : * \param[in] other Other ENUHeading 265 : : * 266 : : * \returns Result of arithmetic operation. 267 : : * 268 : : * \note throws a std::out_of_range exception if one of the two operands or the result of 269 : : * the operation is not valid 270 : : */ 271 : 960 : ENUHeading operator-(const ENUHeading &other) const 272 : : { 273 [ + + ]: 960 : ensureValid(); 274 [ + + ]: 959 : other.ensureValid(); 275 : 958 : ENUHeading const result(mENUHeading - other.mENUHeading); 276 [ + + ]: 958 : result.ensureValid(); 277 : 957 : return result; 278 : : } 279 : : 280 : : /** 281 : : * \brief standard arithmetic operator 282 : : * 283 : : * \param[in] other Other ENUHeading 284 : : * 285 : : * \returns Result of arithmetic operation. 286 : : * 287 : : * \note throws a std::out_of_range exception if one of the two operands or the result of 288 : : * the operation is not valid 289 : : */ 290 : 4 : ENUHeading operator-=(const ENUHeading &other) 291 : : { 292 : 4 : ensureValid(); 293 : 3 : other.ensureValid(); 294 : 2 : mENUHeading -= other.mENUHeading; 295 : 2 : ensureValid(); 296 : 1 : return *this; 297 : : } 298 : : 299 : : /** 300 : : * \brief standard arithmetic operator 301 : : * 302 : : * \param[in] scalar Scalar double value 303 : : * 304 : : * \returns Result of arithmetic operation. 305 : : * 306 : : * \note throws a std::out_of_range exception if \c value or the result of 307 : : * the operation is not valid 308 : : */ 309 : 4 : ENUHeading operator*(const double &scalar) const 310 : : { 311 [ + + ]: 4 : ensureValid(); 312 : 3 : ENUHeading const result(mENUHeading * scalar); 313 [ + + ]: 3 : result.ensureValid(); 314 : 2 : return result; 315 : : } 316 : : 317 : : /** 318 : : * \brief standard arithmetic operator 319 : : * 320 : : * \param[in] scalar Scalar double value 321 : : * 322 : : * \returns Result of arithmetic operation. 323 : : * 324 : : * \note throws a std::out_of_range exception if this or the result of 325 : : * the operation is not valid or other is zero 326 : : */ 327 : 5 : ENUHeading operator/(const double &scalar) const 328 : : { 329 : 5 : ENUHeading const scalarENUHeading(scalar); 330 [ + + ]: 5 : ENUHeading const result(operator/(scalarENUHeading)); 331 [ + + ]: 2 : result.ensureValid(); 332 : 1 : return result; 333 : : } 334 : : 335 : : /** 336 : : * \brief standard arithmetic operator 337 : : * 338 : : * \param[in] other Other ENUHeading 339 : : * 340 : : * \returns Result of arithmetic operation. 341 : : * 342 : : * \note throws a std::out_of_range exception if one of the two operands or the result of 343 : : * the operation is not valid or other is zero 344 : : * \note since ENUHeading is a type with physical unit, the division results in the dimensionless type. 345 : : */ 346 : 9 : double operator/(const ENUHeading &other) const 347 : : { 348 : 9 : ensureValid(); 349 : 7 : other.ensureValidNonZero(); 350 : 3 : double const result = mENUHeading / other.mENUHeading; 351 : 3 : return result; 352 : : } 353 : : 354 : : /** 355 : : * \brief standard arithmetic operator 356 : : * 357 : : * \returns Result of arithmetic operation. 358 : : * 359 : : * \note throws a std::out_of_range exception if this or the result of 360 : : * the operation is not valid 361 : : */ 362 : 2 : ENUHeading operator-() const 363 : : { 364 [ + + ]: 2 : ensureValid(); 365 : 1 : ENUHeading const result(-mENUHeading); 366 : 1 : result.ensureValid(); // LCOV_EXCL_BR_LINE Some types do not throw an exception 367 : 1 : return result; 368 : : } 369 : : 370 : : /*! 371 : : * \brief conversion to base type: double 372 : : * 373 : : * \note the conversion to the base type removes the physical unit. 374 : : * \ref \_AD_MAP_POINT_ENUHEADING_EXPLICIT_CONVERSION\_ defines, if only explicit calls are allowed. 375 : : */ 376 : 983 : _AD_MAP_POINT_ENUHEADING_EXPLICIT_CONVERSION_ operator double() const 377 : : { 378 : 983 : return mENUHeading; 379 : : } 380 : : 381 : : /*! 382 : : * \returns \c true if the ENUHeading in a valid range 383 : : * 384 : : * An ENUHeading value is defined to be valid if: 385 : : * - It is normal or zero (see std::fpclassify()) 386 : : * - \ref cMinValue <= value <= \ref cMaxValue 387 : : */ 388 : 18550 : bool isValid() const 389 : : { 390 : 18550 : auto const valueClass = std::fpclassify(mENUHeading); 391 [ + + + - ]: 18550 : return ((valueClass == FP_NORMAL) || (valueClass == FP_ZERO)) && (cMinValue <= mENUHeading) 392 [ + + + - ]: 37100 : && (mENUHeading <= cMaxValue); 393 : : } 394 : : 395 : : /*! 396 : : * \brief ensure that the ENUHeading is valid 397 : : * 398 : : * Throws an std::out_of_range() exception if the ENUHeading 399 : : * in not valid (i.e. isValid() returns false) 400 : : */ 401 : 18510 : void ensureValid() const 402 : : { 403 [ + + ]: 18510 : if (!isValid()) 404 : : { 405 : 34 : spdlog::info("ensureValid(::ad::map::point::ENUHeading)>> {} value out of range", *this); // LCOV_EXCL_BR_LINE 406 : : #if (AD_MAP_POINT_ENUHEADING_THROWS_EXCEPTION == 1) 407 : 34 : throw std::out_of_range("ENUHeading value out of range"); // LCOV_EXCL_BR_LINE 408 : : #endif 409 : : } 410 : 18476 : } 411 : : 412 : : /*! 413 : : * \brief ensure that the ENUHeading is valid and non zero 414 : : * 415 : : * Throws an std::out_of_range() exception if the ENUHeading 416 : : * in not valid or zero (i.e. isValid() returns false) 417 : : */ 418 : 9 : void ensureValidNonZero() const 419 : : { 420 : 9 : ensureValid(); 421 : 6 : if (operator==(ENUHeading(0.))) // LCOV_EXCL_BR_LINE 422 : : { 423 : 3 : spdlog::info("ensureValid(::ad::map::point::ENUHeading)>> {} value is zero", *this); // LCOV_EXCL_BR_LINE 424 : : #if (AD_MAP_POINT_ENUHEADING_THROWS_EXCEPTION == 1) 425 : 3 : throw std::out_of_range("ENUHeading value is zero"); // LCOV_EXCL_BR_LINE 426 : : #endif 427 : : } 428 : 3 : } 429 : : 430 : : /*! 431 : : * \brief get minimum valid ENUHeading (i.e. \ref cMinValue) 432 : : */ 433 : 26 : static ENUHeading getMin() 434 : : { 435 : 26 : return ENUHeading(cMinValue); 436 : : } 437 : : 438 : : /*! 439 : : * \brief get maximum valid ENUHeading (i.e. \ref cMaxValue) 440 : : */ 441 : 26 : static ENUHeading getMax() 442 : : { 443 : 26 : return ENUHeading(cMaxValue); 444 : : } 445 : : 446 : : /*! 447 : : * \brief get assumed accuracy of ENUHeading (i.e. \ref cPrecisionValue) 448 : : */ 449 : 3 : static ENUHeading getPrecision() 450 : : { 451 : 3 : return ENUHeading(cPrecisionValue); 452 : : } 453 : : 454 : : private: 455 : : /*! 456 : : * \brief the actual value of the type 457 : : */ 458 : : double mENUHeading; 459 : : }; 460 : : 461 : : } // namespace point 462 : : } // namespace map 463 : : } // namespace ad 464 : : /** 465 : : * \brief standard arithmetic operator 466 : : * 467 : : * \param[in] other Other ENUHeading as double value 468 : : * \param[in] value ENUHeading value 469 : : * 470 : : * \returns Result of arithmetic operation. 471 : : * 472 : : * \note throws a std::out_of_range exception if \c value or the result of 473 : : * the operation is not valid 474 : : */ 475 : 1 : inline ::ad::map::point::ENUHeading operator*(const double &other, ::ad::map::point::ENUHeading const &value) 476 : : { 477 : 1 : return value.operator*(other); 478 : : } 479 : : 480 : : /*! 481 : : * \brief namespace std 482 : : */ 483 : : namespace std { 484 : : 485 : : /*! 486 : : * \brief overload of the std::fabs for ENUHeading 487 : : */ 488 : 53 : inline ::ad::map::point::ENUHeading fabs(const ::ad::map::point::ENUHeading other) 489 : : { 490 : 53 : ::ad::map::point::ENUHeading const result(std::fabs(static_cast<double>(other))); 491 : 53 : return result; 492 : : } 493 : : 494 : : /*! 495 : : * \brief specialization of the std::numeric_limits for ENUHeading 496 : : * 497 : : * Derived from std::numeric_limits<double> with overloaded functions: 498 : : * std::numeric_limits<ENUHeading>::lowest() (\see ENUHeading::getMin()) 499 : : * std::numeric_limits<ENUHeading>::max() (\see ENUHeading::getMax()) 500 : : * std::numeric_limits<ENUHeading>::epsilon() (\see ENUHeading::getPrecision()) 501 : : */ 502 : : template <> class numeric_limits<::ad::map::point::ENUHeading> : public numeric_limits<double> 503 : : { 504 : : public: 505 : : /*! 506 : : * \see std::numeric_limits::lowest() 507 : : */ 508 : 24 : static inline ::ad::map::point::ENUHeading lowest() 509 : : { 510 : 24 : return ::ad::map::point::ENUHeading::getMin(); 511 : : } 512 : : /*! 513 : : * \see std::numeric_limits::max() 514 : : */ 515 : 24 : static inline ::ad::map::point::ENUHeading max() 516 : : { 517 : 24 : return ::ad::map::point::ENUHeading::getMax(); 518 : : } 519 : : 520 : : /*! 521 : : * \see std::numeric_limits::epsilon() 522 : : */ 523 : 1 : static inline ::ad::map::point::ENUHeading epsilon() 524 : : { 525 : 1 : return ::ad::map::point::ENUHeading::getPrecision(); 526 : : } 527 : : }; 528 : : 529 : : } // namespace std 530 : : 531 : : /*! 532 : : * \brief protect the definition of functions from duplicates by typedef usage within other data types 533 : : */ 534 : : #ifndef GEN_GUARD_AD_MAP_POINT_ENUHEADING 535 : : #define GEN_GUARD_AD_MAP_POINT_ENUHEADING 536 : : /*! 537 : : * @brief namespace ad 538 : : */ 539 : : namespace ad { 540 : : /*! 541 : : * @brief namespace map 542 : : */ 543 : : namespace map { 544 : : /*! 545 : : * @brief namespace point 546 : : * 547 : : * Handling geographic positions in different coordinate systems 548 : : */ 549 : : namespace point { 550 : : 551 : : /** 552 : : * \brief standard ostream operator 553 : : * 554 : : * \param[in] os The output stream to write to 555 : : * \param[in] _value ENUHeading value 556 : : * 557 : : * \returns The stream object. 558 : : * 559 : : */ 560 : 98 : inline std::ostream &operator<<(std::ostream &os, ENUHeading const &_value) 561 : : { 562 : 98 : return os << double(_value); 563 : : } 564 : : 565 : : } // namespace point 566 : : } // namespace map 567 : : } // namespace ad 568 : : 569 : : namespace std { 570 : : /*! 571 : : * \brief overload of the std::to_string for ENUHeading 572 : : */ 573 : : inline std::string to_string(::ad::map::point::ENUHeading const &value) 574 : : { 575 : : return to_string(static_cast<double>(value)); 576 : : } 577 : : } // namespace std 578 : : #endif // GEN_GUARD_AD_MAP_POINT_ENUHEADING