db.h

00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Michael Moritz                                  *
00003  *   mimo@restoel.net                                                      *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
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 //#include <sqlplus.hh>
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 //#include "dbdefs.h"
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 //      enum { tempCharBuf = 255 };
00075         
00077           // Hook method.
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 

Generated on Tue Jul 24 16:36:53 2007 for gps by  doxygen 1.5.1