migrate UUID class to C++11, untangle includes, cut back compile time
This commit is contained in:
parent
8e89f80588
commit
ba03f99e09
@ -27,17 +27,27 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include "UUID.h"
|
#include "UUID.h"
|
||||||
|
|
||||||
|
#include "OSRMException.h"
|
||||||
|
#include "../typedefs.h"
|
||||||
|
|
||||||
|
#include <boost/uuid/uuid_generators.hpp> // generators
|
||||||
|
#include <boost/uuid/uuid_io.hpp> // streaming operators etc.
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#cmakedefine01 HAS64BITS
|
#cmakedefine01 HAS64BITS
|
||||||
#cmakedefine MD5PREPARE "${MD5PREPARE}"
|
#cmakedefine MD5PREPARE "${MD5PREPARE}"
|
||||||
#cmakedefine MD5RTREE "${MD5RTREE}"
|
#cmakedefine MD5RTREE "${MD5RTREE}"
|
||||||
#cmakedefine MD5GRAPH "${MD5GRAPH}"
|
#cmakedefine MD5GRAPH "${MD5GRAPH}"
|
||||||
#cmakedefine MD5OBJECTS "${MD5OBJECTS}"
|
#cmakedefine MD5OBJECTS "${MD5OBJECTS}"
|
||||||
|
|
||||||
UUID::UUID() : magic_number(1297240911) {
|
UUID::UUID() : magic_number(1297240911)
|
||||||
md5_prepare[32] =
|
{
|
||||||
md5_tree[32] =
|
md5_prepare[32] = md5_tree[32] = md5_graph[32] = md5_objects[32] = '\0';
|
||||||
md5_graph[32] =
|
|
||||||
md5_objects[32] = '\0';
|
|
||||||
|
|
||||||
boost::uuids::name_generator gen(named_uuid);
|
boost::uuids::name_generator gen(named_uuid);
|
||||||
std::string temp_string(__DATE__);
|
std::string temp_string(__DATE__);
|
||||||
@ -56,41 +66,43 @@ UUID::UUID() : magic_number(1297240911) {
|
|||||||
has_64_bits = HAS64BITS;
|
has_64_bits = HAS64BITS;
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID::~UUID() {
|
UUID::~UUID() {}
|
||||||
|
|
||||||
}
|
const boost::uuids::uuid &UUID::GetUUID() const { return named_uuid; }
|
||||||
|
|
||||||
const boost::uuids::uuid & UUID::GetUUID() const {
|
bool UUID::IsMagicNumberOK() const { return 1297240911 == magic_number; }
|
||||||
return named_uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UUID::IsMagicNumberOK() const {
|
bool UUID::TestGraphUtil(const UUID &other) const
|
||||||
return 1297240911 == magic_number;
|
{
|
||||||
}
|
if (!other.IsMagicNumberOK())
|
||||||
|
{
|
||||||
bool UUID::TestGraphUtil(const UUID & other) const {
|
|
||||||
if(!other.IsMagicNumberOK()) {
|
|
||||||
throw OSRMException("hsgr input file misses magic number. Check or reprocess the file");
|
throw OSRMException("hsgr input file misses magic number. Check or reprocess the file");
|
||||||
}
|
}
|
||||||
return std::equal(md5_graph, md5_graph + 32, other.md5_graph);
|
return std::equal(md5_graph, md5_graph + 32, other.md5_graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UUID::TestPrepare(const UUID & other) const {
|
bool UUID::TestPrepare(const UUID &other) const
|
||||||
if(!other.IsMagicNumberOK()) {
|
{
|
||||||
throw OSRMException("extracted input file misses magic number. Check or reprocess the file");
|
if (!other.IsMagicNumberOK())
|
||||||
|
{
|
||||||
|
throw OSRMException("osrm input file misses magic number. Check or reprocess the file");
|
||||||
}
|
}
|
||||||
return std::equal(md5_prepare, md5_prepare + 32, other.md5_prepare);
|
return std::equal(md5_prepare, md5_prepare + 32, other.md5_prepare);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UUID::TestRTree(const UUID & other) const {
|
bool UUID::TestRTree(const UUID &other) const
|
||||||
if(!other.IsMagicNumberOK()) {
|
{
|
||||||
|
if (!other.IsMagicNumberOK())
|
||||||
|
{
|
||||||
throw OSRMException("r-tree input file misses magic number. Check or reprocess the file");
|
throw OSRMException("r-tree input file misses magic number. Check or reprocess the file");
|
||||||
}
|
}
|
||||||
return std::equal(md5_tree, md5_tree + 32, other.md5_tree);
|
return std::equal(md5_tree, md5_tree + 32, other.md5_tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UUID::TestQueryObjects(const UUID & other) const {
|
bool UUID::TestQueryObjects(const UUID &other) const
|
||||||
if(!other.IsMagicNumberOK()) {
|
{
|
||||||
|
if (!other.IsMagicNumberOK())
|
||||||
|
{
|
||||||
throw OSRMException("missing magic number. Check or reprocess the file");
|
throw OSRMException("missing magic number. Check or reprocess the file");
|
||||||
}
|
}
|
||||||
return std::equal(md5_objects, md5_objects + 32, other.md5_objects);
|
return std::equal(md5_objects, md5_objects + 32, other.md5_objects);
|
||||||
|
19
Util/UUID.h
19
Util/UUID.h
@ -28,24 +28,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#ifndef UUID_H
|
#ifndef UUID_H
|
||||||
#define UUID_H
|
#define UUID_H
|
||||||
|
|
||||||
#include "OSRMException.h"
|
#include <boost/uuid/uuid.hpp>
|
||||||
#include "../typedefs.h"
|
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
|
||||||
#include <boost/uuid/uuid.hpp> // uuid class
|
|
||||||
#include <boost/uuid/uuid_generators.hpp> // generators
|
|
||||||
#include <boost/uuid/uuid_io.hpp> // streaming operators etc.
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
// implements a singleton, i.e. there is one and only one conviguration object
|
// implements a singleton, i.e. there is one and only one conviguration object
|
||||||
class UUID : boost::noncopyable {
|
class UUID
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
UUID();
|
UUID();
|
||||||
|
UUID(const UUID&) = delete;
|
||||||
~UUID();
|
~UUID();
|
||||||
const boost::uuids::uuid &GetUUID() const;
|
const boost::uuids::uuid &GetUUID() const;
|
||||||
bool IsMagicNumberOK() const;
|
bool IsMagicNumberOK() const;
|
||||||
@ -54,6 +44,7 @@ public:
|
|||||||
bool TestRTree(const UUID &other) const;
|
bool TestRTree(const UUID &other) const;
|
||||||
bool TestNodeInfo(const UUID &other) const;
|
bool TestNodeInfo(const UUID &other) const;
|
||||||
bool TestQueryObjects(const UUID &other) const;
|
bool TestQueryObjects(const UUID &other) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const unsigned magic_number;
|
const unsigned magic_number;
|
||||||
char md5_prepare[33];
|
char md5_prepare[33];
|
||||||
|
Loading…
Reference in New Issue
Block a user