-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.h
35 lines (29 loc) · 838 Bytes
/
database.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
#ifndef DATABASE_H
#define DATABASE_H
#include <mysql++.h>
#include <vector>
#include <string>
#include <unordered_map>
#include <memory>
#include "user.h"
#include "torrent.h"
class DatabaseConfig;
class Announce;
class User;
class Torrent;
class Database
{
public:
Database(const DatabaseConfig& config);
~Database();
std::shared_ptr<User> getUser(const std::string& passkey);
std::shared_ptr<Torrent> getTorrent(const std::string& infoHash);
void getConfig(std::map<std::string, std::string>& map);
private:
void loadTorrents();
void loadUsers();
mysqlpp::Connection m_connection;
std::unordered_map<std::string, std::shared_ptr<User> > m_users;
std::unordered_map<std::string, std::shared_ptr<Torrent> > m_torrents;
};
#endif // DATABASE_H