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