11#include "Arp/System/Core/Enum.hxx" 
   16namespace Arp { 
namespace System { 
namespace Nm { 
namespace Internal
 
   28template<
typename T, 
typename TypeTag>
 
   31    static_assert(std::is_unsigned<T>::value, 
"T must be an unsigned integer type");
 
   32    static_assert(std::is_same<T, bool>::value == 0, 
"Cannot be used with bool");
 
   40    constexpr IdType() noexcept = default;
 
   45    constexpr explicit 
IdType(T value) noexcept : Value(value)
 
   49    constexpr IdType(
const self_type&) 
noexcept = 
default;
 
   53        other.Value = self_type().Value;
 
   59    self_type& operator=(const self_type&) noexcept = default;
 
   61    self_type& operator=(
IdType&& other) noexcept
 
   63        this->Value = other.Value;
 
   64        other.Value = self_type().Value;
 
   69    constexpr bool operator<(
const self_type& rhs) 
const noexcept 
   71        return this->Value < rhs.Value;
 
   75    constexpr bool operator==(
const self_type& rhs) 
const noexcept 
   77        return this->Value == rhs.Value;
 
   81    constexpr bool operator!=(
const self_type& rhs) 
const noexcept 
   83        return this->Value != rhs.Value;
 
  102    constexpr static const self_type GetIncrementedId(
const self_type& 
id) 
noexcept 
  104        return self_type(
static_cast<T
>(
id.Value + 1));
 
  108    constexpr static const self_type CreateInitalId() noexcept
 
  110        return GetIncrementedId(self_type());
 
  114    constexpr const self_type CreateNextIdUnique() const noexcept
 
  116        return GetIncrementedId(*
this);
 
  120    constexpr const self_type CreateNextId() const noexcept
 
  122        return this->IsValid() ? this->CreateNextIdUnique() : self_type();
 
  127    T Value = std::numeric_limits<T>::min();
 
  129    friend Internal::IdGenerator<self_type>;
 
  133template<
typename T, 
typename TypeTag>
 
  143template<
typename IdType>
 
  146    std::vector<typename IdType::type> result;
 
  147    result.reserve(ids.size());
 
  148    for (
const IdType& each : ids)
 
  150        result.emplace_back(each.GetValue());
 
  158template<
typename IdType>
 
  161    std::vector<IdType> result;
 
  162    result.reserve(ids.size());
 
  163    for (
const typename IdType::type& each : ids)
 
  165        result.emplace_back(
IdType(each));
 
  177template<
typename T, 
typename TypeTag>
 
  178struct hash<
Arp::System::Nm::IdType<T, TypeTag>>
 
  181    using result_type = std::size_t;
 
  184        return std::hash<T>()(
id.GetValue());
 
  189template<
typename T, 
typename TypeTag>
 
  190struct fmt::formatter<
Arp::System::Nm::IdType<T, TypeTag>>: 
public fmt::ostream_formatter {};
 
Representation of an unique id
Definition: IdType.hpp:30
 
constexpr T GetValue() const noexcept
Returns the underlying value
Definition: IdType.hpp:95
 
constexpr bool IsValid() const noexcept
Returns true if this object represents a valid id (!= 0)
Definition: IdType.hpp:88
 
constexpr IdType() noexcept=default
Creates an invalid id
 
std::vector< typename IdType::type > ConvertIdTypesToRawIds(const std::vector< IdType > &ids)
Converts a vector of IdType to a vector of the underlying type
Definition: IdType.hpp:144
 
std::vector< IdType > ConvertRawIdsToIdTypes(const std::vector< typename IdType::type > &ids)
Converts a vector of underlying ids to a vector of IdType
Definition: IdType.hpp:159
 
Root namespace for the PLCnext API
 
Namespace of the C++ standard library