uuid handling improved
This commit is contained in:
parent
7a6c664014
commit
74b7f5f57f
2 changed files with 24 additions and 8 deletions
|
@ -1,7 +1,20 @@
|
||||||
#include "entity.h"
|
#include "entity.h"
|
||||||
|
|
||||||
#include <boost/uuid/uuid_generators.hpp>
|
#include <iostream>
|
||||||
|
|
||||||
Entity::Entity() : uuid(boost::uuids::random_generator()())
|
#include <boost/uuid/uuid_generators.hpp>
|
||||||
|
#include <boost/uuid/uuid_io.hpp>
|
||||||
|
|
||||||
|
Entity::Entity() {}
|
||||||
|
|
||||||
|
void Entity::createUuid()
|
||||||
{
|
{
|
||||||
|
static boost::uuids::random_generator generator{};
|
||||||
|
uuid = generator();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Entity::createUuidFromString(const std::string& uuid_string)
|
||||||
|
{
|
||||||
|
boost::uuids::string_generator generator{};
|
||||||
|
uuid = generator(uuid_string);
|
||||||
}
|
}
|
|
@ -9,10 +9,13 @@ class Entity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Entity();
|
Entity();
|
||||||
~Entity();
|
virtual ~Entity() = 0;
|
||||||
const boost::uuids::uuid& getUuid() { return uuid; };
|
const boost::uuids::uuid& getUuid() { return uuid; };
|
||||||
|
void createUuid();
|
||||||
|
void createUuidFromString(const std::string& uuid_string);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::uuids::uuid uuid;
|
boost::uuids::uuid uuid{};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ENTITY_H
|
#endif // ENTITY_H
|
Loading…
Reference in a new issue