-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdatabase.h
More file actions
51 lines (48 loc) · 1.39 KB
/
database.h
File metadata and controls
51 lines (48 loc) · 1.39 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
50
51
/**
*Database class that uses Hiredis library. It conceals the more technical aspects about the Hiredis library.
*-Stephen Mingolelli
*-Nicola Mingolelli
*/
#ifndef DATABASE_H_
#define DATABASE_H_
#include <string>
#include "item.h"
#include <iostream>
#include "hiredis.h"
#include <vector>
class Item;
class Room;
class Player;
class Database{
private:
redisContext *context;
vector<Item*> items;
vector<Room*> rooms;
vector<Player*> players;
public:
//values
int lastid;
Database(); //default constructor
//methods
void write(std::string, std::string);
std::string read(std::string) const;
Item * read_lastid_item(int);
Room * read_lastid_room(int);
Player * read_lastid_player(int);
void increment_lastid();
void addPlayer(Player*);
Player * findPlayerById(int);
Player * findPlayerByName(std::string);
void addItem(Item*);
Item * findItemByName(std::string);
void addRoom(Room*);
Room * findRoomByName(std::string);
vector<Room*> getRooms();
vector<Player*> getPlayers();
void clearDatabase(); //FLUSHALL
void deleteObject(int id);
void deleteRoom(int id);
void deleteItem(int id);
void deletePlayer(int id);
};
#endif