00001 /* -*- Mode: c++ -*- 00002 * Copyright 2006 (C) Stuart Auchterlonie <stuarta at squashedfrog.net> 00003 * License: GPL v2 00004 */ 00005 00006 #ifndef _EIT_CACHE_H 00007 #define _EIT_CACHE_H 00008 00009 #include <stdint.h> 00010 00011 // Qt headers 00012 #include <qmap.h> 00013 #include <qmutex.h> 00014 #include <qstring.h> 00015 00016 #include "mythexp.h" 00017 00018 typedef QMap<uint, uint64_t> event_map_t; 00019 typedef QMap<uint, event_map_t*> key_map_t; 00020 00021 class EITCache 00022 { 00023 public: 00024 EITCache(); 00025 ~EITCache(); 00026 00027 bool IsNewEIT(uint chanid, uint tableid, uint version, 00028 uint eventid, uint endtime); 00029 00030 uint PruneOldEntries(uint utc_timestamp); 00031 void WriteToDB(void); 00032 00033 void ResetStatistics(void); 00034 QString GetStatistics(void) const; 00035 00036 private: 00037 event_map_t * LoadChannel(uint chanid); 00038 void WriteChannelToDB(uint chanid); 00039 00040 // event key cache 00041 key_map_t channelMap; 00042 00043 mutable QMutex eventMapLock; 00044 uint lastPruneTime; 00045 00046 // statistics 00047 uint accessCnt; 00048 uint hitCnt; 00049 uint tblChgCnt; 00050 uint verChgCnt; 00051 uint entryCnt; 00052 uint pruneCnt; 00053 uint prunedHitCnt; 00054 uint wrongChannelHitCnt; 00055 00056 static const uint kVersionMax; 00057 00058 public: 00059 static MPUBLIC void ClearChannelLocks(void); 00060 }; 00061 00062 #endif // _EIT_CACHE_H 00063 00064 /* vim: set expandtab tabstop=4 shiftwidth=4: */
1.5.5