-
Notifications
You must be signed in to change notification settings - Fork 2
/
BackEnd.hpp
59 lines (44 loc) · 1.36 KB
/
BackEnd.hpp
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
#ifndef _BACKEND_H_
#define _BACKEND_H_
#include "QueryResult.hpp"
#include "User.hpp"
//boost
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
//std
#include <stdint.h>
#include <fstream>
#include <vector>
//sql
#include <cppconn/connection.h>
class IBackEnd
{
public:
virtual ~IBackEnd() {}
// siehe: IFrontEnd::matchAd
// XXX see why this wont fucking work
virtual QueryResult matchAdRewrites(const std::vector<std::string>& rewriteList,
const IUser* user = NULL,
bool* foundAd = NULL) = 0;
// siehe: IFrontEnd::getAdURL
virtual std::string getAdURL(uint32_t adID) = 0;
// Datenbank mit Ads und Bid Phrases initialisieren
virtual bool initDatabase(const std::string& adFile, const std::string& bidPhraseFile) = 0;
};
class BackEnd : public IBackEnd
{
public:
BackEnd(boost::shared_ptr<sql::Connection> con) : con(con) { }
virtual ~BackEnd() {}
virtual QueryResult matchAdRewrites(const std::vector<std::string>& rewriteList,
const IUser* user = NULL,
bool* foundAd = NULL);
// siehe: IFrontEnd::getAdURL
virtual std::string getAdURL(uint32_t adID);
// Datenbank mit Ads und Bid Phrases initialisieren
virtual bool initDatabase(const std::string& adFile, const std::string& bidPhraseFile);
private:
boost::shared_ptr<sql::Connection> con;
bool tablesExist();
};
#endif /* _BACKEND_H_ */