Line | Count | Source |
1 | | /* |
2 | | * |
3 | | * (C) 2013-25 - ntop.org |
4 | | * |
5 | | * |
6 | | * This program is free software; you can redistribute it and/or modify |
7 | | * it under the terms of the GNU General Public License as published by |
8 | | * the Free Software Foundation; either version 3 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * This program is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License |
17 | | * along with this program; if not, write to the Free Software Foundation, |
18 | | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | | * |
20 | | */ |
21 | | |
22 | | #ifndef _DB_CLASS_H_ |
23 | | #define _DB_CLASS_H_ |
24 | | |
25 | | #include "ntop_includes.h" |
26 | | |
27 | | typedef int db_result_row_callback(std::vector<std::string> *row, std::vector<std::string> *columns, void *user_data); |
28 | | |
29 | | class DB { |
30 | | private: |
31 | | |
32 | | protected: |
33 | | NetworkInterface *iface; |
34 | | bool running; |
35 | | |
36 | | public: |
37 | | DB(NetworkInterface *_iface); |
38 | 4 | virtual ~DB(){}; |
39 | | |
40 | 0 | virtual const char *getEngineName() { return "Unknown"; }; |
41 | 0 | virtual bool startDumpLoop() { return false; } |
42 | | |
43 | | virtual int execSQLQuery(const char *sql, |
44 | | bool doReconnect = true, bool ignoreErrors = false, |
45 | 0 | db_result_row_callback *cb = NULL, void *cb_user_data = NULL) { |
46 | 0 | return (-1); |
47 | 0 | } |
48 | | |
49 | | virtual int execSQLQuery(lua_State *vm, const char *sql, |
50 | 0 | bool limitRows, bool wait_for_db_created) { |
51 | 0 | return (-1); |
52 | 0 | } |
53 | | |
54 | | virtual int execSQLQuery2CSV(const char *sql, bool dump_in_json_format, |
55 | 0 | struct mg_connection *mg_conn) { |
56 | 0 | return (-1); |
57 | 0 | } |
58 | | |
59 | 0 | virtual void archiveData(time_t epoch_begin, time_t epoch_end) {} |
60 | | |
61 | 0 | inline NetworkInterface *getNetworkInterface() { return iface; }; |
62 | 0 | inline void startDBLoop() { if (startDumpLoop()) running = true; }; |
63 | 0 | inline int isRunning() { return (running); }; |
64 | 0 | virtual bool isDbCreated() { return (true); }; |
65 | | virtual void shutdown(); |
66 | 0 | virtual void flush() {}; |
67 | 0 | virtual void checkIdle(time_t when) { ; } |
68 | | }; |
69 | | |
70 | | #endif /* _DB_CLASS_H_ */ |