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
|
#include "database.h"
#include <config.h>
#include <stdlib.h>
#include "debug.h"
#include "pracrodaopgsql.h"
#include "pracrodaotest.h"
Database::Database(std::string _backend, std::string _host, std::string _port, std::string _user, std::string _passwd, std::string _dbname)
{
dao = NULL;
#ifndef WITHOUT_DB
if(_backend == "pgsql") {
PRACRO_DEBUG(db, "construct(%s, %s, %s, %s, %s)\n", _host.c_str(), _port.c_str(), _user.c_str(), _passwd.c_str(), _dbname.c_str());
dao = new PracroDAOPgsql(_host, _port, _user, _passwd, _dbname);
}
#endif
if(_backend == "testdb") {
Data data;
dao = new PracroDAOTest(data, true);
}
}
Database::~Database()
{
#ifndef WITHOUT_DB
if(dao) delete dao;
#endif
}
|