/* * Paglo Crawler * Copyright (C) 2006-2008 Paglo Labs Inc. All rights reserved. * www.paglo.com * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ //--------------------------------------------------------------------------- #ifndef DataStoreH #define DataStoreH //--------------------------------------------------------------------------- #include "CppSQLite3.h" #include "ScanAgentUtils.h" class TDataStore { public: /* * Create the data store using the specified file on disk. If the file * does not exist then create a new database with that name. */ TDataStore(const char *Filename); virtual ~TDataStore(void); void UpdateScanSummary(int WeekHour, int CompletedScans); int *GetScanSummary(void); /* * Execute a SQL statement. */ void ExecuteStmt(string SQL); protected: /* * Caller must hold query lock. */ CppSQLite3Query ExecuteQuery(string SQL); /* * Lock for executing statements/queries. */ TLock QueryLock; void CreateDatabase(const char *Filename); void OpenDatabase(const char *Filename); void CloseDatabase(void); /* * Handle migration of the DB schema. */ int GetDBVersion(); void Migrate(); private: const char *DBFilename; /* * The SQLITE database instance. */ CppSQLite3DB *DB; }; //--------------------------------------------------------------------------- #endif