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_io.hpp>
|
||||
|
||||
//Entity::Entity() {}
|
||||
|
||||
Entity::~Entity() {}
|
||||
|
||||
void Entity::createUuid()
|
||||
{
|
||||
static boost::uuids::random_generator generator{};
|
||||
uuid = generator();
|
||||
uuid_ = generator();
|
||||
}
|
||||
|
||||
void Entity::createUuidFromString(const std::string& uuidString)
|
||||
{
|
||||
boost::uuids::string_generator generator{};
|
||||
uuid = generator(uuidString);
|
||||
uuid_ = generator(uuidString);
|
||||
}
|
||||
|
||||
inline Entity::State Entity::getState()
|
||||
{
|
||||
return state_;
|
||||
}
|
|
@ -8,14 +8,17 @@
|
|||
class Entity
|
||||
{
|
||||
public:
|
||||
//Entity();
|
||||
enum class State { NEW, UPDATED, READ };
|
||||
// Entity();
|
||||
virtual ~Entity() = 0;
|
||||
const boost::uuids::uuid& getUuid() const { return uuid; };
|
||||
const boost::uuids::uuid& getUuid() const { return uuid_; };
|
||||
void createUuid();
|
||||
void createUuidFromString(const std::string& uuidString);
|
||||
State getState();
|
||||
|
||||
private:
|
||||
boost::uuids::uuid uuid{};
|
||||
boost::uuids::uuid uuid_{};
|
||||
State state_{State::NEW};
|
||||
};
|
||||
|
||||
#endif // ENTITY_H
|
|
@ -2,25 +2,25 @@
|
|||
|
||||
void Seller::setSellerNo(int seller_no)
|
||||
{
|
||||
this->sellerNo = seller_no;
|
||||
sellerNo_ = seller_no;
|
||||
}
|
||||
|
||||
void Seller::setFirstName(const std::string& firstName)
|
||||
{
|
||||
this->firstName = firstName;
|
||||
firstName_ = firstName;
|
||||
}
|
||||
|
||||
void Seller::setLastName(const std::string& lastName)
|
||||
{
|
||||
this->lastName = lastName;
|
||||
lastName_ = lastName;
|
||||
}
|
||||
|
||||
void Seller::setNumberOfOfferedArticles(int number)
|
||||
{
|
||||
numberOfOfferedArticles = number;
|
||||
numberOfOfferedArticles_ = number;
|
||||
}
|
||||
|
||||
size_t Seller::getNumberOfOfferedArticles()
|
||||
{
|
||||
return articles.size();
|
||||
return articles_.size();
|
||||
}
|
|
@ -20,11 +20,11 @@ class Seller : public Entity
|
|||
size_t getNumberOfOfferedArticles();
|
||||
|
||||
private:
|
||||
int sellerNo{};
|
||||
int numberOfOfferedArticles{};
|
||||
std::string firstName{};
|
||||
std::string lastName{};
|
||||
std::vector<Article> articles{};
|
||||
int sellerNo_{-1};
|
||||
int numberOfOfferedArticles_{};
|
||||
std::string firstName_{};
|
||||
std::string lastName_{};
|
||||
std::vector<Article> articles_{};
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue