From 7c40ea6f9795486b08dadcebfbe437fbd118015e Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Thu, 12 Jul 2018 12:15:27 +0200 Subject: [PATCH] use non-owning raw pointers in getArticles() --- src/core/seller.cpp | 12 +++++++----- src/core/seller.h | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/core/seller.cpp b/src/core/seller.cpp index 5e7edae..94d3a0d 100644 --- a/src/core/seller.cpp +++ b/src/core/seller.cpp @@ -30,15 +30,17 @@ std::string Seller::getLastName() const { return lastName_; } int Seller::getSellerNo() const { return sellerNo_; } -std::vector> Seller::getArticles(bool onlySold) +std::vector Seller::getArticles(bool onlySold) const { - std::vector> articles; + std::vector articles; for (const auto article : articles_) { if (onlySold && article->isSold()) { - articles.push_back(article); + articles.push_back(article.get()); } else if (!onlySold) { - articles.push_back(article); + articles.push_back(article.get()); } } return articles; -} \ No newline at end of file +} + +size_t Seller::soldArticles() const { return getArticles(true).size(); } \ No newline at end of file diff --git a/src/core/seller.h b/src/core/seller.h index 63aebb2..a713292 100644 --- a/src/core/seller.h +++ b/src/core/seller.h @@ -27,7 +27,8 @@ class Seller : public Entity std::string getLastName() const; int getSellerNo() const; int getNumberOfOfferedArticles() const; - std::vector> getArticles(bool onlySold = false); + size_t soldArticles() const; + std::vector getArticles(bool onlySold = false) const; private: int sellerNo_{-1};