mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Implement missing functions, fixes linking errors
This commit is contained in:
64
lib/constants/IdentifierBase.h
Normal file
64
lib/constants/IdentifierBase.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* IdentifierBase.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
class IdentifierBase
|
||||
{
|
||||
protected:
|
||||
constexpr IdentifierBase():
|
||||
num(-1)
|
||||
{}
|
||||
|
||||
explicit constexpr IdentifierBase(int32_t value):
|
||||
num(value)
|
||||
{}
|
||||
|
||||
~IdentifierBase() = default;
|
||||
public:
|
||||
int32_t num;
|
||||
|
||||
constexpr int32_t getNum() const
|
||||
{
|
||||
return num;
|
||||
}
|
||||
|
||||
constexpr void setNum(int32_t value)
|
||||
{
|
||||
num = value;
|
||||
}
|
||||
|
||||
struct hash
|
||||
{
|
||||
size_t operator()(const IdentifierBase & id) const
|
||||
{
|
||||
return std::hash<int>()(id.num);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & num;
|
||||
}
|
||||
|
||||
constexpr void advance(int change)
|
||||
{
|
||||
num += change;
|
||||
}
|
||||
|
||||
constexpr operator int32_t () const
|
||||
{
|
||||
return num;
|
||||
}
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os, const IdentifierBase& dt)
|
||||
{
|
||||
return os << dt.num;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user