more work on entities
This commit is contained in:
parent
97e444c91c
commit
be9c951d02
4 changed files with 23 additions and 17 deletions
|
@ -5,18 +5,21 @@
|
||||||
#include <boost/uuid/uuid_generators.hpp>
|
#include <boost/uuid/uuid_generators.hpp>
|
||||||
#include <boost/uuid/uuid_io.hpp>
|
#include <boost/uuid/uuid_io.hpp>
|
||||||
|
|
||||||
//Entity::Entity() {}
|
|
||||||
|
|
||||||
Entity::~Entity() {}
|
Entity::~Entity() {}
|
||||||
|
|
||||||
void Entity::createUuid()
|
void Entity::createUuid()
|
||||||
{
|
{
|
||||||
static boost::uuids::random_generator generator{};
|
static boost::uuids::random_generator generator{};
|
||||||
uuid = generator();
|
uuid_ = generator();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::createUuidFromString(const std::string& uuidString)
|
void Entity::createUuidFromString(const std::string& uuidString)
|
||||||
{
|
{
|
||||||
boost::uuids::string_generator generator{};
|
boost::uuids::string_generator generator{};
|
||||||
uuid = generator(uuidString);
|
uuid_ = generator(uuidString);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Entity::State Entity::getState()
|
||||||
|
{
|
||||||
|
return state_;
|
||||||
}
|
}
|
|
@ -8,14 +8,17 @@
|
||||||
class Entity
|
class Entity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//Entity();
|
enum class State { NEW, UPDATED, READ };
|
||||||
|
// Entity();
|
||||||
virtual ~Entity() = 0;
|
virtual ~Entity() = 0;
|
||||||
const boost::uuids::uuid& getUuid() const { return uuid; };
|
const boost::uuids::uuid& getUuid() const { return uuid_; };
|
||||||
void createUuid();
|
void createUuid();
|
||||||
void createUuidFromString(const std::string& uuidString);
|
void createUuidFromString(const std::string& uuidString);
|
||||||
|
State getState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::uuids::uuid uuid{};
|
boost::uuids::uuid uuid_{};
|
||||||
|
State state_{State::NEW};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ENTITY_H
|
#endif // ENTITY_H
|
|
@ -2,25 +2,25 @@
|
||||||
|
|
||||||
void Seller::setSellerNo(int seller_no)
|
void Seller::setSellerNo(int seller_no)
|
||||||
{
|
{
|
||||||
this->sellerNo = seller_no;
|
sellerNo_ = seller_no;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Seller::setFirstName(const std::string& firstName)
|
void Seller::setFirstName(const std::string& firstName)
|
||||||
{
|
{
|
||||||
this->firstName = firstName;
|
firstName_ = firstName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Seller::setLastName(const std::string& lastName)
|
void Seller::setLastName(const std::string& lastName)
|
||||||
{
|
{
|
||||||
this->lastName = lastName;
|
lastName_ = lastName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Seller::setNumberOfOfferedArticles(int number)
|
void Seller::setNumberOfOfferedArticles(int number)
|
||||||
{
|
{
|
||||||
numberOfOfferedArticles = number;
|
numberOfOfferedArticles_ = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Seller::getNumberOfOfferedArticles()
|
size_t Seller::getNumberOfOfferedArticles()
|
||||||
{
|
{
|
||||||
return articles.size();
|
return articles_.size();
|
||||||
}
|
}
|
|
@ -20,11 +20,11 @@ class Seller : public Entity
|
||||||
size_t getNumberOfOfferedArticles();
|
size_t getNumberOfOfferedArticles();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int sellerNo{};
|
int sellerNo_{-1};
|
||||||
int numberOfOfferedArticles{};
|
int numberOfOfferedArticles_{};
|
||||||
std::string firstName{};
|
std::string firstName_{};
|
||||||
std::string lastName{};
|
std::string lastName_{};
|
||||||
std::vector<Article> articles{};
|
std::vector<Article> articles_{};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in a new issue