diff --git a/src/openrct2/core/Identifier.hpp b/src/openrct2/core/Identifier.hpp new file mode 100644 index 0000000000..ffebd40aba --- /dev/null +++ b/src/openrct2/core/Identifier.hpp @@ -0,0 +1,61 @@ +/***************************************************************************** + * Copyright (c) 2014-2021 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include +#include +#include + +template class TIdentifier +{ + enum class ValueType : T + { + Null = TNullValue, + } _handle; + +private: + explicit TIdentifier(const T index) + : _handle{ static_cast(index) } + { + } + +public: + static constexpr auto Null = ValueType::Null; + + TIdentifier(const ValueType other) + : _handle{ other } + { + } + + static constexpr TIdentifier FromUnderlying(const T val) noexcept + { + return TIdentifier{ val }; + } + + constexpr T ToUnderlying() const noexcept + { + return static_cast(_handle); + } + + constexpr bool IsNull() const noexcept + { + return _handle == ValueType::Null; + } + + constexpr bool operator==(const ValueType other) const noexcept + { + return _handle == other; + } + + constexpr bool operator!=(const ValueType other) const noexcept + { + return _handle != other; + } +}; diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 7af0b34048..37ecfead94 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -169,6 +169,7 @@ +