uuid handling improved

This commit is contained in:
Martin Brodbeck 2018-07-09 13:03:25 +02:00
parent 7a6c664014
commit 74b7f5f57f
2 changed files with 24 additions and 8 deletions

View file

@ -1,7 +1,20 @@
#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);
}

View file

@ -7,12 +7,15 @@
class Entity
{
public:
public:
Entity();
~Entity();
const boost::uuids::uuid& getUuid() {return uuid;};
private:
boost::uuids::uuid uuid;
virtual ~Entity() = 0;
const boost::uuids::uuid& getUuid() { return uuid; };
void createUuid();
void createUuidFromString(const std::string& uuid_string);
private:
boost::uuids::uuid uuid{};
};
#endif //ENTITY_H
#endif // ENTITY_H