-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmydatastore.h
More file actions
49 lines (41 loc) · 1.3 KB
/
mydatastore.h
File metadata and controls
49 lines (41 loc) · 1.3 KB
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
#ifndef MYDATASTORE_H
#define MYDATASTORE_H
#include <string>
#include <set>
#include <vector>
#include <map>
#include "product.h"
#include "user.h"
#include "datastore.h"
class MyDataStore : public DataStore{
public:
~MyDataStore();
/**
* Adds a product to the data store
*/
void addProduct(Product* p);
/**
* Adds a user to the data store
*/
void addUser(User* u);
void addCart(std::string username, Product* p);
/**
* Performs a search of products whose keywords match the given "terms"
* type 0 = AND search (intersection of results for each term) while
* type 1 = OR search (union of results for each term)
*/
std::vector<Product*> search(std::vector<std::string>& terms, int type);
std::vector<Product*> getCart(std::string username);
void buyCart(std::string username);
void viewCart(std::vector<Product*> vect);
/**
* Reproduce the database file from the current Products and User values
*/
void dump(std::ostream& ofile);
private:
//first in first out, act like a queue
std::vector<Product*> products_;
std::set<User*> users_;
std::map<User*, std::vector<Product*>> cart_;
};
#endif