2015-01-27 11:44:46 -05:00
|
|
|
#ifndef FINGERPRINT_H
|
|
|
|
#define FINGERPRINT_H
|
|
|
|
|
2017-01-06 16:45:08 -05:00
|
|
|
#include <array>
|
2015-01-27 11:44:46 -05:00
|
|
|
#include <boost/uuid/uuid.hpp>
|
2017-01-06 16:45:08 -05:00
|
|
|
#include <cstdint>
|
2015-06-19 11:48:27 -04:00
|
|
|
#include <type_traits>
|
2015-01-27 11:44:46 -05:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace util
|
|
|
|
{
|
|
|
|
|
2015-01-27 11:44:46 -05:00
|
|
|
// implements a singleton, i.e. there is one and only one conviguration object
|
2016-05-12 12:50:10 -04:00
|
|
|
struct FingerPrint
|
2015-01-27 11:44:46 -05:00
|
|
|
{
|
2015-06-18 12:34:25 -04:00
|
|
|
static FingerPrint GetValid();
|
2017-01-06 16:45:08 -05:00
|
|
|
|
|
|
|
bool IsValid() const;
|
|
|
|
bool IsDataCompatible(const FingerPrint &other) const;
|
|
|
|
|
|
|
|
int GetMajorVersion() const;
|
|
|
|
int GetMinorVersion() const;
|
|
|
|
int GetPatchVersion() const;
|
2015-01-27 11:44:46 -05:00
|
|
|
|
|
|
|
private:
|
2017-01-06 16:45:08 -05:00
|
|
|
std::uint8_t CalculateChecksum() const;
|
|
|
|
// Here using std::array so that == can be used to conveniently compare contents
|
|
|
|
std::array<std::uint8_t, 4> magic_number;
|
|
|
|
std::uint8_t major_version;
|
|
|
|
std::uint8_t minor_version;
|
|
|
|
std::uint8_t patch_version;
|
|
|
|
std::uint8_t checksum; // CRC8 of the previous bytes to ensure the fingerprint is not damaged
|
2015-01-27 11:44:46 -05:00
|
|
|
};
|
|
|
|
|
2017-01-06 16:45:08 -05:00
|
|
|
static_assert(sizeof(FingerPrint) == 8, "FingerPrint has unexpected size");
|
2015-06-19 11:48:27 -04:00
|
|
|
static_assert(std::is_trivial<FingerPrint>::value, "FingerPrint needs to be trivial.");
|
2016-05-12 12:50:10 -04:00
|
|
|
static_assert(std::is_pod<FingerPrint>::value, "FingerPrint needs to be a POD.");
|
2016-01-05 10:51:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-27 11:44:46 -05:00
|
|
|
#endif /* FingerPrint_H */
|