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 <cstdint> 22 : : #include <iostream> 23 : : #include <limits> 24 : : #include <sstream> 25 : : #include <stdexcept> 26 : : #include "spdlog/fmt/ostr.h" 27 : : #include "spdlog/spdlog.h" 28 : : /*! 29 : : * @brief namespace ad 30 : : */ 31 : : namespace ad { 32 : : /*! 33 : : * @brief namespace map 34 : : */ 35 : : namespace map { 36 : : /*! 37 : : * @brief namespace access 38 : : * 39 : : * Accessing map data 40 : : */ 41 : : namespace access { 42 : : 43 : : /*! 44 : : * \brief Define to indicate whether throwing exceptions is enabled 45 : : */ 46 : : #define AD_MAP_ACCESS_PARTITIONID_THROWS_EXCEPTION 1 47 : : 48 : : #if SAFE_DATATYPES_EXPLICIT_CONVERSION 49 : : /*! 50 : : * \brief Enable/Disable explicit conversion. Currently set to "only explicit conversion". 51 : : */ 52 : : #define _AD_MAP_ACCESS_PARTITIONID_EXPLICIT_CONVERSION_ explicit 53 : : #else 54 : : /*! 55 : : * \brief Enable/Disable explicit conversion. Currently set to "implicit conversion allowed". 56 : : */ 57 : : #define _AD_MAP_ACCESS_PARTITIONID_EXPLICIT_CONVERSION_ 58 : : #endif 59 : : 60 : : /*! 61 : : * \brief DataType PartitionId 62 : : * 63 : : * Defines the id of an partition of the map. 64 : : * The unit is: Identifier 65 : : */ 66 : : class PartitionId 67 : : { 68 : : public: 69 : : /*! 70 : : * \brief constant defining the minimum valid PartitionId value (used in isValid()) 71 : : */ 72 : : static const uint64_t cMinValue; 73 : : 74 : : /*! 75 : : * \brief constant defining the maximum valid PartitionId value (used in isValid()) 76 : : */ 77 : : static const uint64_t cMaxValue; 78 : : 79 : : /*! 80 : : * \brief default constructor 81 : : * 82 : : * The default value of PartitionId is: 83 : : * std::numeric_limits<uint64_t>::quiet_NaN() 84 : : */ 85 : 269 : PartitionId() 86 : 269 : : mPartitionId(std::numeric_limits<uint64_t>::quiet_NaN()) 87 : : { 88 : 269 : } 89 : : 90 : : /*! 91 : : * \brief standard constructor 92 : : * 93 : : * \note \ref \_AD_MAP_ACCESS_PARTITIONID_EXPLICIT_CONVERSION\_ defines, if only an explicit conversion is allowed. 94 : : */ 95 : 30690 : _AD_MAP_ACCESS_PARTITIONID_EXPLICIT_CONVERSION_ PartitionId(uint64_t const iPartitionId) 96 : 30690 : : mPartitionId(iPartitionId) 97 : : { 98 : 30690 : } 99 : : 100 : : /*! 101 : : * \brief standard copy constructor 102 : : */ 103 : : PartitionId(const PartitionId &other) = default; 104 : : 105 : : /*! 106 : : * \brief standard move constructor 107 : : */ 108 : : PartitionId(PartitionId &&other) = default; 109 : : 110 : : /** 111 : : * \brief standard assignment operator 112 : : * 113 : : * \param[in] other Other PartitionId 114 : : * 115 : : * \returns Reference to this PartitionId. 116 : : */ 117 : : PartitionId &operator=(const PartitionId &other) = default; 118 : : 119 : : /** 120 : : * \brief standard move operator 121 : : * 122 : : * \param[in] other Other PartitionId 123 : : * 124 : : * \returns Reference to this PartitionId. 125 : : */ 126 : : PartitionId &operator=(PartitionId &&other) = default; 127 : : 128 : : /** 129 : : * \brief standard comparison operator 130 : : * 131 : : * \param[in] other Other PartitionId 132 : : * 133 : : * \returns \c true if both PartitionId are valid and can be taken as numerically equal 134 : : */ 135 : 12 : bool operator==(const PartitionId &other) const 136 : : { 137 : 12 : ensureValid(); 138 : 12 : other.ensureValid(); 139 : 12 : return mPartitionId == other.mPartitionId; 140 : : } 141 : : 142 : : /** 143 : : * \brief standard comparison operator 144 : : * 145 : : * \param[in] other Other PartitionId. 146 : : * 147 : : * \returns \c true if one of the PartitionId is not valid or they can be taken as numerically different 148 : : */ 149 : 3 : bool operator!=(const PartitionId &other) const 150 : : { 151 : 3 : return !operator==(other); 152 : : } 153 : : 154 : : /** 155 : : * \brief standard comparison operator 156 : : * 157 : : * \param[in] other Other PartitionId. 158 : : * 159 : : * \returns \c true if both PartitionId are valid and 160 : : * this PartitionId is strictly numerically greater than other. 161 : : * \note the precision of PartitionId is considered 162 : : */ 163 : 1 : bool operator>(const PartitionId &other) const 164 : : { 165 : 1 : ensureValid(); 166 : 1 : other.ensureValid(); 167 [ + - + - ]: 1 : return (mPartitionId > other.mPartitionId) && operator!=(other); 168 : : } 169 : : 170 : : /** 171 : : * \brief standard comparison operator 172 : : * 173 : : * \param[in] other Other PartitionId. 174 : : * 175 : : * \returns \c true if both PartitionId are valid and 176 : : * this PartitionId is strictly numerically smaller than other. 177 : : * \note the precision of PartitionId is considered 178 : : */ 179 : 49429 : bool operator<(const PartitionId &other) const 180 : : { 181 : 49429 : ensureValid(); 182 : 49429 : other.ensureValid(); 183 [ + + + - ]: 49429 : return (mPartitionId < other.mPartitionId) && operator!=(other); 184 : : } 185 : : 186 : : /** 187 : : * \brief standard comparison operator 188 : : * 189 : : * \param[in] other Other PartitionId. 190 : : * 191 : : * \returns \c true if both PartitionId are valid and 192 : : * this PartitionId is numerically greater than other. 193 : : * \note the precision of PartitionId is considered 194 : : */ 195 : 1 : bool operator>=(const PartitionId &other) const 196 : : { 197 : 1 : ensureValid(); 198 : 1 : other.ensureValid(); 199 [ - + - - ]: 1 : return ((mPartitionId > other.mPartitionId) || operator==(other)); 200 : : } 201 : : 202 : : /** 203 : : * \brief standard comparison operator 204 : : * 205 : : * \param[in] other Other PartitionId 206 : : * 207 : : * \returns \c true if both PartitionId are valid and 208 : : * this PartitionId is numerically smaller than other. 209 : : * \note the precision of PartitionId is considered 210 : : */ 211 : 5 : bool operator<=(const PartitionId &other) const 212 : : { 213 : 5 : ensureValid(); 214 : 5 : other.ensureValid(); 215 [ + + + - ]: 5 : return ((mPartitionId < other.mPartitionId) || operator==(other)); 216 : : } 217 : : 218 : : /** 219 : : * \brief standard arithmetic operator 220 : : * 221 : : * \param[in] other Other PartitionId 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 : 1 : PartitionId operator+(const PartitionId &other) const 229 : : { 230 [ + - ]: 1 : ensureValid(); 231 [ + - ]: 1 : other.ensureValid(); 232 : 1 : PartitionId const result(mPartitionId + other.mPartitionId); 233 [ + - ]: 1 : result.ensureValid(); 234 : 1 : return result; 235 : : } 236 : : 237 : : /** 238 : : * \brief standard arithmetic operator 239 : : * 240 : : * \param[in] other Other PartitionId 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 : 1 : PartitionId &operator+=(const PartitionId &other) 248 : : { 249 : 1 : ensureValid(); 250 : 1 : other.ensureValid(); 251 : 1 : mPartitionId += other.mPartitionId; 252 : 1 : ensureValid(); 253 : 1 : return *this; 254 : : } 255 : : 256 : : /** 257 : : * \brief standard arithmetic operator 258 : : * 259 : : * \param[in] other Other PartitionId 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 : 1 : PartitionId operator-(const PartitionId &other) const 267 : : { 268 [ + - ]: 1 : ensureValid(); 269 [ + - ]: 1 : other.ensureValid(); 270 : 1 : PartitionId const result(mPartitionId - other.mPartitionId); 271 [ + - ]: 1 : result.ensureValid(); 272 : 1 : return result; 273 : : } 274 : : 275 : : /** 276 : : * \brief standard arithmetic operator 277 : : * 278 : : * \param[in] other Other PartitionId 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 : 1 : PartitionId operator-=(const PartitionId &other) 286 : : { 287 : 1 : ensureValid(); 288 : 1 : other.ensureValid(); 289 : 1 : mPartitionId -= other.mPartitionId; 290 : 1 : ensureValid(); 291 : 1 : return *this; 292 : : } 293 : : 294 : : /*! 295 : : * \brief conversion to base type: uint64_t 296 : : * 297 : : * \note the conversion to the base type removes the physical unit. 298 : : * \ref \_AD_MAP_ACCESS_PARTITIONID_EXPLICIT_CONVERSION\_ defines, if only explicit calls are allowed. 299 : : */ 300 : 35 : _AD_MAP_ACCESS_PARTITIONID_EXPLICIT_CONVERSION_ operator uint64_t() const 301 : : { 302 : 35 : return mPartitionId; 303 : : } 304 : : 305 : : /*! 306 : : * \returns \c true if the PartitionId in a valid range 307 : : * 308 : : * An PartitionId value is defined to be valid if: 309 : : * - It is normal or zero (see std::fpclassify()) 310 : : * - \ref cMinValue <= value <= \ref cMaxValue 311 : : */ 312 : 98922 : bool isValid() const 313 : : { 314 : 98922 : auto const valueClass = std::fpclassify(mPartitionId); 315 [ + - + - ]: 98922 : return ((valueClass == FP_NORMAL) || (valueClass == FP_ZERO)) && (cMinValue <= mPartitionId) 316 [ + + + - ]: 197844 : && (mPartitionId <= cMaxValue); 317 : : } 318 : : 319 : : /*! 320 : : * \brief ensure that the PartitionId is valid 321 : : * 322 : : * Throws an std::out_of_range() exception if the PartitionId 323 : : * in not valid (i.e. isValid() returns false) 324 : : */ 325 : 98910 : void ensureValid() const 326 : : { 327 [ - + ]: 98910 : if (!isValid()) 328 : : { 329 : 0 : spdlog::info("ensureValid(::ad::map::access::PartitionId)>> {} value out of range", *this); // LCOV_EXCL_BR_LINE 330 : : #if (AD_MAP_ACCESS_PARTITIONID_THROWS_EXCEPTION == 1) 331 : 0 : throw std::out_of_range("PartitionId value out of range"); // LCOV_EXCL_BR_LINE 332 : : #endif 333 : : } 334 : 98910 : } 335 : : 336 : : /*! 337 : : * \brief ensure that the PartitionId is valid and non zero 338 : : * 339 : : * Throws an std::out_of_range() exception if the PartitionId 340 : : * in not valid or zero (i.e. isValid() returns false) 341 : : */ 342 : 2 : void ensureValidNonZero() const 343 : : { 344 : 2 : ensureValid(); 345 : 2 : if (operator==(PartitionId(0))) // LCOV_EXCL_BR_LINE 346 : : { 347 : 2 : spdlog::info("ensureValid(::ad::map::access::PartitionId)>> {} value is zero", *this); // LCOV_EXCL_BR_LINE 348 : : #if (AD_MAP_ACCESS_PARTITIONID_THROWS_EXCEPTION == 1) 349 : 2 : throw std::out_of_range("PartitionId value is zero"); // LCOV_EXCL_BR_LINE 350 : : #endif 351 : : } 352 : 0 : } 353 : : 354 : : /*! 355 : : * \brief get minimum valid PartitionId (i.e. \ref cMinValue) 356 : : */ 357 : 7 : static PartitionId getMin() 358 : : { 359 : 7 : return PartitionId(cMinValue); 360 : : } 361 : : 362 : : /*! 363 : : * \brief get maximum valid PartitionId (i.e. \ref cMaxValue) 364 : : */ 365 : 5 : static PartitionId getMax() 366 : : { 367 : 5 : return PartitionId(cMaxValue); 368 : : } 369 : : 370 : : private: 371 : : /*! 372 : : * \brief the actual value of the type 373 : : */ 374 : : uint64_t mPartitionId; 375 : : }; 376 : : 377 : : } // namespace access 378 : : } // namespace map 379 : : } // namespace ad 380 : : /*! 381 : : * \brief namespace std 382 : : */ 383 : : namespace std { 384 : : 385 : : /*! 386 : : * \brief specialization of the std::numeric_limits for PartitionId 387 : : * 388 : : * Derived from std::numeric_limits<uint64_t> with overloaded functions: 389 : : * std::numeric_limits<PartitionId>::lowest() (\see PartitionId::getMin()) 390 : : * std::numeric_limits<PartitionId>::max() (\see PartitionId::getMax()) 391 : : * std::numeric_limits<PartitionId>::epsilon() (\see PartitionId::getPrecision()) 392 : : */ 393 : : template <> class numeric_limits<::ad::map::access::PartitionId> : public numeric_limits<uint64_t> 394 : : { 395 : : public: 396 : : /*! 397 : : * \see std::numeric_limits::lowest() 398 : : */ 399 : 4 : static inline ::ad::map::access::PartitionId lowest() 400 : : { 401 : 4 : return ::ad::map::access::PartitionId::getMin(); 402 : : } 403 : : /*! 404 : : * \see std::numeric_limits::max() 405 : : */ 406 : 3 : static inline ::ad::map::access::PartitionId max() 407 : : { 408 : 3 : return ::ad::map::access::PartitionId::getMax(); 409 : : } 410 : : 411 : : /*! 412 : : * \see std::numeric_limits::epsilon() 413 : : */ 414 : : static inline ::ad::map::access::PartitionId epsilon() 415 : : { 416 : : return ::ad::map::access::PartitionId(0); 417 : : } 418 : : }; 419 : : 420 : : } // namespace std 421 : : 422 : : /*! 423 : : * \brief protect the definition of functions from duplicates by typedef usage within other data types 424 : : */ 425 : : #ifndef GEN_GUARD_AD_MAP_ACCESS_PARTITIONID 426 : : #define GEN_GUARD_AD_MAP_ACCESS_PARTITIONID 427 : : /*! 428 : : * @brief namespace ad 429 : : */ 430 : : namespace ad { 431 : : /*! 432 : : * @brief namespace map 433 : : */ 434 : : namespace map { 435 : : /*! 436 : : * @brief namespace access 437 : : * 438 : : * Accessing map data 439 : : */ 440 : : namespace access { 441 : : 442 : : /** 443 : : * \brief standard ostream operator 444 : : * 445 : : * \param[in] os The output stream to write to 446 : : * \param[in] _value PartitionId value 447 : : * 448 : : * \returns The stream object. 449 : : * 450 : : */ 451 : 3 : inline std::ostream &operator<<(std::ostream &os, PartitionId const &_value) 452 : : { 453 : 3 : return os << uint64_t(_value); 454 : : } 455 : : 456 : : } // namespace access 457 : : } // namespace map 458 : : } // namespace ad 459 : : 460 : : namespace std { 461 : : /*! 462 : : * \brief overload of the std::to_string for PartitionId 463 : : */ 464 : : inline std::string to_string(::ad::map::access::PartitionId const &value) 465 : : { 466 : : return to_string(static_cast<uint64_t>(value)); 467 : : } 468 : : } // namespace std 469 : : #endif // GEN_GUARD_AD_MAP_ACCESS_PARTITIONID