#include "Gallery.h" #include Gallery::Gallery(std::string name) : name(name) { } void Gallery::addArtwork(Artwork *artwork) { artworks.push_back(artwork); } void Gallery::printArtworks() const { for (auto &artwork: artworks) std::cout << artwork->toString() << std::endl; } std::string Gallery::toString() const { std::string ret; for (auto &artwork: artworks) ret += artwork->toString() + "\n\n"; return ret; } void Gallery::sort(bool (*c)(Artwork *, Artwork *)) { std::sort(artworks.begin(),artworks.end(), c); } Artwork *Gallery::find(bool (*c)(Artwork *)) { auto it = std::find_if(artworks.begin(),artworks.end(),c); return *it; } void Gallery::printArtworks(PrintIfPainting i) { std::for_each(artworks.begin(),artworks.end(),i); } std::vector Gallery::filteredVector(bool (*c)(Artwork *)) { std::vector tmp; for (int i = 0; i < artworks.size(); ++i) { if(c(artworks[i])){ tmp.push_back(artworks[i]); } } return tmp; };