consolidate all repos to one for archive
This commit is contained in:
57
semester_2/programiranje_2/naloga1002/Gallery.h
Normal file
57
semester_2/programiranje_2/naloga1002/Gallery.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef NALOGA0201_GALLERY_H
|
||||
#define NALOGA0201_GALLERY_H
|
||||
|
||||
#include "Artwork.h"
|
||||
#include "Painting.h"
|
||||
#include "Literature.h"
|
||||
#include "PaintingLiterature.h"
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
|
||||
struct PrintIfPainting
|
||||
{
|
||||
void operator()(std::shared_ptr<Artwork> e)
|
||||
{
|
||||
std::shared_ptr<Painting> derived;
|
||||
derived = std::dynamic_pointer_cast<Painting>(e);
|
||||
if (derived)
|
||||
{
|
||||
std::cout << derived->toString() << "\n";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class Gallery
|
||||
{
|
||||
private:
|
||||
std::string name;
|
||||
std::vector<std::shared_ptr<Artwork>> artworks;
|
||||
public:
|
||||
Gallery() = default;
|
||||
|
||||
explicit Gallery(std::string name);
|
||||
|
||||
~Gallery() = default;
|
||||
|
||||
void addArtwork(std::shared_ptr<Artwork> artwork);
|
||||
|
||||
void printArtworks() const;
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
int getSize() const;
|
||||
|
||||
void sort(std::function<bool(std::shared_ptr<Artwork>, std::shared_ptr<Artwork>)> c);
|
||||
|
||||
std::shared_ptr<Artwork> find(std::function<bool(std::shared_ptr<Artwork>)> c);
|
||||
|
||||
void printArtworks(PrintIfPainting i);
|
||||
|
||||
void filterOut(std::function<bool(std::shared_ptr<Artwork>)> c);
|
||||
};
|
||||
|
||||
#endif //NALOGA0201_GALLERY_H
|
||||
|
||||
Reference in New Issue
Block a user