-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnection.h
43 lines (32 loc) · 923 Bytes
/
connection.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
36
37
38
39
40
41
42
43
#ifndef __connection_h
#define __connection_h
#include <map>
#include <vector>
#include <boost/thread.hpp>
#include <boost/thread/tss.hpp>
#include <mysql/mysql.h>
namespace cot {
// Connection class is a singleton. There would be the connections
// pool in the upcomming release.
class Connection
{
private:
typedef void (*destroy_pointer_t)();
class Resource
{
public:
MYSQL connect;
~Resource() {
mysql_close(&connect);
}
};
static boost::thread_specific_ptr<Resource> resource;
public:
static void connect(const char *, /* host */
const char *, /* user */
const char *, /* password */
const char *); /* db name */
static MYSQL * connection();
};
} // namespace cot
#endif