Compare commits

..

3 commits

Author SHA1 Message Date
96113653e7 code cleanup 2018-07-09 16:07:04 +02:00
8f3dda3520 ... 2018-07-09 16:06:39 +02:00
0c72b31953 New classes added 2018-07-09 16:06:27 +02:00
7 changed files with 119 additions and 9 deletions

View file

@ -3,13 +3,16 @@
find_package(Boost 1.62 REQUIRED)
find_package(SQLite3 REQUIRED)
set(CORE_HEADERS
entity.h
database.h
)
#set(CORE_HEADERS
# entity.h
# database.h
#)
set(CORE_SOURCES
entity.cpp
database.cpp
entity.cpp
seller.cpp
article.cpp
)
add_library(core STATIC ${CORE_SOURCES})

24
src/core/article.cpp Normal file
View file

@ -0,0 +1,24 @@
#include "article.h"
Article::Article() : Entity()
{}
Article::Article(const std::shared_ptr<Seller> sellerPtr) : Entity()
{
this->sellerPtr = sellerPtr;
}
void Article::setArticleNo(int articleNo)
{
this->articleNo = articleNo;
}
void Article::setPrice(int price)
{
this->price = price;
}
void Article::setDescription(const std::string& description)
{
this->description = description;
}

27
src/core/article.h Normal file
View file

@ -0,0 +1,27 @@
#ifndef ARTICLE_H
#define ARTICLE_H
#include "entity.h"
#include "seller.h"
#include <string>
#include <memory>
class Seller;
class Article : public Entity
{
public:
Article();
Article(std::shared_ptr<Seller> sellerPtr);
void setArticleNo(int articleNo);
void setPrice(int price);
void setDescription(const std::string& description);
private:
std::shared_ptr<Seller> sellerPtr{};
int articleNo{};
int price{};
std::string description{};
};
#endif

View file

@ -13,8 +13,8 @@ void Entity::createUuid()
uuid = generator();
}
void Entity::createUuidFromString(const std::string& uuid_string)
void Entity::createUuidFromString(const std::string& uuidString)
{
boost::uuids::string_generator generator{};
uuid = generator(uuid_string);
uuid = generator(uuidString);
}

View file

@ -10,9 +10,9 @@ class Entity
public:
Entity();
virtual ~Entity() = 0;
const boost::uuids::uuid& getUuid() { return uuid; };
const boost::uuids::uuid& getUuid() const { return uuid; };
void createUuid();
void createUuidFromString(const std::string& uuid_string);
void createUuidFromString(const std::string& uuidString);
private:
boost::uuids::uuid uuid{};

26
src/core/seller.cpp Normal file
View file

@ -0,0 +1,26 @@
#include "seller.h"
void Seller::setSellerNo(int seller_no)
{
this->sellerNo = seller_no;
}
void Seller::setFirstName(const std::string& firstName)
{
this->firstName = firstName;
}
void Seller::setLastName(const std::string& lastName)
{
this->lastName = lastName;
}
void Seller::setNumberOfOfferedArticles(int number)
{
numberOfOfferedArticles = number;
}
size_t Seller::getNumberOfOfferedArticles()
{
return articles.size();
}

30
src/core/seller.h Normal file
View file

@ -0,0 +1,30 @@
#ifndef SELLER_H
#define SELLER_H
#include "entity.h"
#include "article.h"
#include <string>
#include <vector>
class Article;
class Seller : public Entity
{
public:
void setSellerNo(int sellerNo);
void setFirstName(const std::string& firstName);
void setLastName(const std::string& lastName);
void setNumberOfOfferedArticles(int number);
size_t getNumberOfOfferedArticles();
private:
int sellerNo{};
int numberOfOfferedArticles{};
std::string firstName{};
std::string lastName{};
std::vector<Article> articles{};
};
#endif