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