files renamed
This commit is contained in:
parent
dd23da5f72
commit
46d6468e5c
8 changed files with 80 additions and 11 deletions
|
@ -13,6 +13,7 @@ endif (MINGW)
|
||||||
set(CORE_SOURCES
|
set(CORE_SOURCES
|
||||||
database.cpp
|
database.cpp
|
||||||
entity.cpp
|
entity.cpp
|
||||||
|
entityuuid.cpp
|
||||||
seller.cpp
|
seller.cpp
|
||||||
article.cpp
|
article.cpp
|
||||||
sale.cpp
|
sale.cpp
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef ARTICLE_H
|
#ifndef ARTICLE_H
|
||||||
#define ARTICLE_H
|
#define ARTICLE_H
|
||||||
|
|
||||||
#include "entity.h"
|
#include "entityuuid.h"
|
||||||
//#include "sale.h"
|
//#include "sale.h"
|
||||||
//#include "seller.h"
|
//#include "seller.h"
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
class Seller;
|
class Seller;
|
||||||
class Sale;
|
class Sale;
|
||||||
|
|
||||||
class Article : public Entity
|
class Article : public EntityUuid
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Article() = default;
|
Article() = default;
|
||||||
|
|
33
src/core/entityuuid.cpp
Normal file
33
src/core/entityuuid.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#include "entityuuid.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <boost/uuid/uuid_generators.hpp>
|
||||||
|
#include <boost/uuid/uuid_io.hpp>
|
||||||
|
|
||||||
|
EntityUuid::~EntityUuid() = default;
|
||||||
|
|
||||||
|
void EntityUuid::createUuid()
|
||||||
|
{
|
||||||
|
static boost::uuids::random_generator generator{};
|
||||||
|
uuid_ = generator();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EntityUuid::setUuidFromString(const std::string& uuidString)
|
||||||
|
{
|
||||||
|
boost::uuids::string_generator generator{};
|
||||||
|
uuid_ = generator(uuidString);
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity::State EntityUuid::getState() const
|
||||||
|
{
|
||||||
|
return state_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EntityUuid::setSourceNo(int sourceNo) {
|
||||||
|
sourceNo_ = sourceNo;
|
||||||
|
}
|
||||||
|
|
||||||
|
int EntityUuid::getSourceNo() const {
|
||||||
|
return sourceNo_;
|
||||||
|
}
|
35
src/core/entityuuid.h
Normal file
35
src/core/entityuuid.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef ENTITY_UUID_H
|
||||||
|
#define ENTITY_UUID_H
|
||||||
|
|
||||||
|
#include "entity.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <boost/uuid/uuid.hpp>
|
||||||
|
#include <boost/uuid/uuid_io.hpp>
|
||||||
|
|
||||||
|
class EntityUuid : public Entity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Entity() = default;
|
||||||
|
virtual ~EntityUuid() = 0;
|
||||||
|
|
||||||
|
void createUuid();
|
||||||
|
void setUuidFromString(const std::string& uuidString);
|
||||||
|
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_{};
|
||||||
|
State state_{State::NEW};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ENTITY_UUID_H
|
|
@ -14,7 +14,7 @@ namespace
|
||||||
using ArticlesVec = std::vector<Article*>;
|
using ArticlesVec = std::vector<Article*>;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Sale : public Entity
|
class Sale : public EntityUuid
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void addArticle(Article* articlePtr);
|
void addArticle(Article* articlePtr);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
Seller::Seller(const std::string& firstName, const std::string& lastName, int sellerNo,
|
Seller::Seller(const std::string& firstName, const std::string& lastName, int sellerNo,
|
||||||
int numArticlesOffered)
|
int numArticlesOffered)
|
||||||
: Entity()
|
: EntityUuid()
|
||||||
{
|
{
|
||||||
firstName_ = firstName;
|
firstName_ = firstName;
|
||||||
lastName_ = lastName;
|
lastName_ = lastName;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define SELLER_H
|
#define SELLER_H
|
||||||
|
|
||||||
#include "article.h"
|
#include "article.h"
|
||||||
#include "entity.h"
|
#include "entityuuid.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
// class Article;
|
// class Article;
|
||||||
|
|
||||||
class Seller : public Entity
|
class Seller : public EntityUuid
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Seller() = default;
|
Seller() = default;
|
||||||
|
|
|
@ -44,7 +44,7 @@ QModelIndex SaleModel::parent(const QModelIndex& index) const
|
||||||
Sale* sale{};
|
Sale* sale{};
|
||||||
Article* article{};
|
Article* article{};
|
||||||
|
|
||||||
Entity* ent = static_cast<Entity*>(index.internalPointer());
|
EntityUuid* ent = static_cast<EntityUuid*>(index.internalPointer());
|
||||||
|
|
||||||
sale = dynamic_cast<Sale*>(ent);
|
sale = dynamic_cast<Sale*>(ent);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue