Add entity files to git

This commit is contained in:
Martin Brodbeck 2019-10-04 15:22:15 +02:00
parent 63f9822f34
commit a33b9896b3
4 changed files with 25 additions and 50 deletions

View File

@ -1,33 +1,6 @@
#include "entity.h"
#include <iostream>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
Entity::~Entity() = default;
void Entity::createUuid()
{
static boost::uuids::random_generator generator{};
uuid_ = generator();
}
void Entity::setUuidFromString(const std::string& uuidString)
{
boost::uuids::string_generator generator{};
uuid_ = generator(uuidString);
}
Entity::State Entity::getState() const
{
return state_;
}
void Entity::setSourceNo(int sourceNo) {
sourceNo_ = sourceNo;
}
int Entity::getSourceNo() const {
return sourceNo_;
}

View File

@ -1,35 +1,16 @@
#ifndef ENTITY_H
#define ENTITY_H
#include <string>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
class Entity
{
public:
public:
enum class State { NEW, UPDATE, DELETE, OK };
// Entity() = default;
virtual ~Entity() = 0;
void createUuid();
void setUuidFromString(const std::string& uuidString);
//virtual ~Entity() = 0;
void setState(State state) { state_ = state; }
void setSourceNo(int sourceNo);
const boost::uuids::uuid& getUuid() const { return uuid_; };
std::string getUuidAsString() const { return boost::uuids::to_string(uuid_); }
virtual State getState() const;
virtual int getSourceNo() const;
protected:
int sourceNo_{};
private:
boost::uuids::uuid uuid_{};
private:
State state_{State::NEW};
};
#endif // ENTITY_H
#endif // ENTITY_H

5
src/core/entityint.cpp Normal file
View File

@ -0,0 +1,5 @@
#include "entityint.h"
void EntityInt::setId(int id) {
id_ = id;
}

16
src/core/entityint.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef ENTITY_INT_H
#define ENTITY_INT_H
#include "entity.h"
class EntityInt : public Entity
{
public:
void setId(int id);
int getId() const {return id_;};
protected:
int id_{};
};
#endif // ENTITY_INT_H