Add entity files to git
This commit is contained in:
parent
63f9822f34
commit
a33b9896b3
4 changed files with 25 additions and 50 deletions
|
@ -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_;
|
||||
}
|
|
@ -1,34 +1,15 @@
|
|||
#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};
|
||||
};
|
||||
|
||||
|
|
5
src/core/entityint.cpp
Normal file
5
src/core/entityint.cpp
Normal file
|
@ -0,0 +1,5 @@
|
|||
#include "entityint.h"
|
||||
|
||||
void EntityInt::setId(int id) {
|
||||
id_ = id;
|
||||
}
|
16
src/core/entityint.h
Normal file
16
src/core/entityint.h
Normal 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
|
Loading…
Reference in a new issue