DBServer_MySQL.h

См. документацию.
00001 /* This file is part of the UniSet project
00002  * Copyright (c) 2002 Free Software Foundation, Inc.
00003  * Copyright (c) 2002 Pavel Vainerman
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 Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018  */
00019 // --------------------------------------------------------------------------
00023 // -------------------------------------------------------------------------- 
00024 #ifndef DBServer_MySQL_H_
00025 #define DBServer_MySQL_H_
00026 // --------------------------------------------------------------------------
00027 #include <map>
00028 #include <queue>
00029 #include "UniSetTypes.h"
00030 #include "DBInterface.h"
00031 #include "DBServer.h"
00032 //------------------------------------------------------------------------------------------
00146 class DBServer_MySQL: 
00147     public DBServer
00148 {
00149     public:
00150         DBServer_MySQL( UniSetTypes::ObjectId id );
00151         DBServer_MySQL();
00152         ~DBServer_MySQL();
00153 
00154         static const Debug::type DBLogInfoLevel = Debug::LEVEL9;
00155 
00156     protected:
00157         typedef std::map<int, std::string> DBTableMap;
00158 
00159         virtual void initDB(DBInterface *db){};
00160         virtual void initDBTableMap(DBTableMap& tblMap){};
00161 
00162         virtual void processingMessage( UniSetTypes::VoidMessage *msg );
00163         virtual void timerInfo( UniSetTypes::TimerMessage* tm );
00164         virtual void sysCommand( UniSetTypes::SystemMessage* sm );
00165 
00166         // Функции обработки пришедших сообщений
00167         virtual void parse( UniSetTypes::SensorMessage* sm );
00168         virtual void parse( UniSetTypes::DBMessage* dbmsg );
00169         virtual void parse( UniSetTypes::InfoMessage* imsg );
00170         virtual void parse( UniSetTypes::AlarmMessage* amsg );
00171         virtual void parse( UniSetTypes::ConfirmMessage* cmsg );
00172 
00173         bool writeToBase( const string& query );
00174         virtual void init_dbserver();
00175         void createTables( DBInterface* db );
00176         
00177         inline const char* tblName(int key)
00178         {
00179             return tblMap[key].c_str();
00180         }
00181 
00182         enum Timers
00183         {
00184             PingTimer,        
00185             ReconnectTimer,   
00186             lastNumberOfTimer
00187         };
00188 
00189 
00190         DBInterface *db;
00191         int PingTime;
00192         int ReconnectTime;
00193         bool connect_ok;    
00195         bool activate;
00196 
00197         typedef std::queue<std::string> QueryBuffer;
00198 
00199         QueryBuffer qbuf;
00200         unsigned int qbufSize; // размер буфера сообщений.
00201         bool lastRemove;
00202 
00203         void flushBuffer();
00204         UniSetTypes::uniset_mutex mqbuf;
00205 
00206     private:
00207         DBTableMap tblMap;
00208 
00209 };
00210 //------------------------------------------------------------------------------------------
00211 #endif

Документация по UniSet. Последние изменения: Tue Jul 10 20:46:18 2012. Создано системой  doxygen 1.5.5