-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxmdb_factory.cpp
60 lines (51 loc) · 1.01 KB
/
xmdb_factory.cpp
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
/*
* lmdb_factory.cpp
*
* Created on: Jul 11, 2017
*/
#include "xmdb.h"
static const char *paths[] = {
"lmdb-userinfo",
"lmdb02",
"lmdb03",
"lmdb04",
"lmdb05",
"lmdb06",
"lmdb07",
"lmdb08",
"lmdb09",
"lmdb10",
"lmdb11",
"lmdb12",
"lmdb13",
"lmdb14",
"lmdb15",
"lmdb16",
};
static xmdb *lmdb_handles[16];
xmdb* xmdb::get_instance(int index)
{
if (lmdb_handles[index] == 0) {
lmdb_handles[index] = new xmdb(paths[index]);
}
return lmdb_handles[index];
}
xmdb* xmdb::get_instance(const std::string &dbname)
{
int index = -1;
for (unsigned int i=0; i<sizeof(paths)/sizeof(paths[0]); ++i)
{
if ( paths[i] == dbname )
{
index = i;
break;
}
}
if ( index < 0 ){
return 0;
}
if (lmdb_handles[index] == 0) {
lmdb_handles[index] = new xmdb(paths[index]);
}
return lmdb_handles[index];
}