use non-owning raw pointers in getArticles()
This commit is contained in:
parent
d64606c861
commit
7c40ea6f97
2 changed files with 9 additions and 6 deletions
|
@ -30,15 +30,17 @@ std::string Seller::getLastName() const { return lastName_; }
|
||||||
|
|
||||||
int Seller::getSellerNo() const { return sellerNo_; }
|
int Seller::getSellerNo() const { return sellerNo_; }
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Article>> Seller::getArticles(bool onlySold)
|
std::vector<Article*> Seller::getArticles(bool onlySold) const
|
||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<Article>> articles;
|
std::vector<Article*> articles;
|
||||||
for (const auto article : articles_) {
|
for (const auto article : articles_) {
|
||||||
if (onlySold && article->isSold()) {
|
if (onlySold && article->isSold()) {
|
||||||
articles.push_back(article);
|
articles.push_back(article.get());
|
||||||
} else if (!onlySold) {
|
} else if (!onlySold) {
|
||||||
articles.push_back(article);
|
articles.push_back(article.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return articles;
|
return articles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t Seller::soldArticles() const { return getArticles(true).size(); }
|
|
@ -27,7 +27,8 @@ class Seller : public Entity
|
||||||
std::string getLastName() const;
|
std::string getLastName() const;
|
||||||
int getSellerNo() const;
|
int getSellerNo() const;
|
||||||
int getNumberOfOfferedArticles() const;
|
int getNumberOfOfferedArticles() const;
|
||||||
std::vector<std::shared_ptr<Article>> getArticles(bool onlySold = false);
|
size_t soldArticles() const;
|
||||||
|
std::vector<Article*> getArticles(bool onlySold = false) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int sellerNo_{-1};
|
int sellerNo_{-1};
|
||||||
|
|
Loading…
Reference in a new issue