-
Notifications
You must be signed in to change notification settings - Fork 0
/
StoreFactory.cpp
32 lines (28 loc) · 1.03 KB
/
StoreFactory.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
#include "StoreFactory.h"
#include "SQLiteStore.h"
#include "MySQLStore.h"
#ifdef USE_HANDLERSOCKET
#include "HSStore.h"
#endif
#include <string.h>
#define CREATE_STORE(name, class) \
if (strcmp(type, name) == 0) \
{ \
class* store = new class(file); \
store->onReport = (class::ReportHandler)handler; \
if (store->checkConnectionError()) \
{ \
delete store; \
return NULL; \
} \
return store; \
}
DDBClient::Store* StoreFactory::createStore(const char* type, const char* file, DDBClient::ReportHandler handler)
{
CREATE_STORE("SQLite3", SQLiteStore);
CREATE_STORE("MySQL", MySQLStore);
#ifdef USE_HANDLERSOCKET
CREATE_STORE("HandlerSocket", HSStore);
#endif
return NULL;
}