-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinventory.h
69 lines (52 loc) · 1.38 KB
/
inventory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* Inventory.h
* Inventory class holds a map with all movies in the store.
*
* @author Olga Kuriatnyk
*/
#ifndef INVENTORY_H
#define INVENTORY_H
#include <algorithm>
#include <cassert>
#include <fstream>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#include "movie.h"
class Inventory {
public:
// function to get an Instance of all inventory
static Inventory &getInstance() {
static Inventory instance;
return instance;
}
// constructor
Inventory() = default;
// copy not allowed
Inventory(const Inventory &other) = delete;
// move not allowed
Inventory(Inventory &&other) = delete;
// assignment not allowed
Inventory &operator=(const Inventory &other) = delete;
// move assignment not allowed
Inventory &operator=(Inventory &&other) = delete;
// destructor
~Inventory();
// insert new item to inventory map
void insert(Movie *item);
// retrieve item, if not found @return nullptr
Movie *retrieve(char movieType, const ItemKey &itemKey);
// sort items in the inventory
void sortItems();
// to print inventory
void printInventory();
private:
static Inventory *instance;
// key - movieType, value - vector of items
map<char, vector<Movie *>, greater<char> > inventory;
// helper function for sorting elements insive the vector
void sortByAtributes(vector<Movie *> &items);
};
#endif