2018-09-22 15:36:57 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_OBJECTID_H
|
|
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_OBJECTID_H
|
|
|
|
|
|
|
|
#include <cstddef>
|
2023-04-21 00:13:40 +00:00
|
|
|
#include <functional>
|
2018-09-22 15:36:57 +00:00
|
|
|
|
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
|
|
|
class ObjectId
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
template <class T>
|
2020-10-10 10:08:27 +00:00
|
|
|
explicit ObjectId(T* value) noexcept
|
2018-09-22 15:36:57 +00:00
|
|
|
: mValue(reinterpret_cast<std::size_t>(value))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-06-29 01:49:21 +00:00
|
|
|
explicit ObjectId(std::size_t value) noexcept
|
|
|
|
: mValue(value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-10-10 10:08:27 +00:00
|
|
|
std::size_t value() const noexcept { return mValue; }
|
2018-09-22 15:36:57 +00:00
|
|
|
|
2020-10-10 10:08:27 +00:00
|
|
|
friend bool operator<(const ObjectId lhs, const ObjectId rhs) noexcept { return lhs.mValue < rhs.mValue; }
|
2018-09-22 15:36:57 +00:00
|
|
|
|
2020-10-10 10:08:27 +00:00
|
|
|
friend bool operator==(const ObjectId lhs, const ObjectId rhs) noexcept { return lhs.mValue == rhs.mValue; }
|
2018-09-22 15:36:57 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::size_t mValue;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
template <>
|
|
|
|
struct hash<DetourNavigator::ObjectId>
|
|
|
|
{
|
2020-10-10 10:08:27 +00:00
|
|
|
std::size_t operator()(const DetourNavigator::ObjectId value) const noexcept { return value.value(); }
|
2018-09-22 15:36:57 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|