00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __DB_H
00021 #define __DB_H
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026
00027
00028 #include <iosfwd>
00029 #include <string>
00030
00031 #include <exception>
00032 #include <dbi/dbi.h>
00033 #include <vector>
00034 #include <list>
00035 #include "triplet.h"
00036 #include "wlmodule.h"
00037 #include "signals.h"
00038
00039
00044 class DB : public Event_Handler
00045 {
00046 public:
00047 typedef std::vector<std::string> ParamVector;
00048 DB() throw(std::exception);
00049
00051 typedef enum {
00052 unknown,
00053 waiting,
00054 registered
00055 } RecordStatus;
00056 RecordStatus update(const class Triplet&) throw(std::exception);
00057
00059 void list_drivers(std::ostream &os);
00060
00061 ~DB() { close(); }
00062
00064 std::string getConError(const std::string&) const;
00065
00067 void createTable(const class WLStaticDef& staticDef) throw(std::exception);
00068
00069 bool exactMatch(const std::string& logprefix,const class WLStaticDef& staticDef,
00070 const class Triplet& triplet) throw(std::exception);
00071
00072 dbi_result executeSQL(const std::string& sql) throw(std::exception);
00073
00074
00075
00077
00078 virtual int handle_signal(int signum);
00079 protected:
00080 const std::string trimLastByte(std::string);
00081 std::string getSqlCondition(const WLCompares& compares,const Triplet& triplet) const;
00082 const std::string numToStr(unsigned) const;
00083 std::string getWeakHost(const std::string&) const throw(std::exception);
00084
00086 void open() throw(std::exception);
00087
00089 void close();
00090
00092 void init_wlMods();
00093 private:
00094 dbi_conn _con;
00095 static const std::string _sql_table_test;
00096 typedef std::list<WlModule*>WlModuleList;
00097 WlModuleList _wlMods;
00098 sig_atomic_t _graceful_quit;
00099 };
00100
00101 #endif
00102