Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

ctdatacache.h

Go to the documentation of this file.
00001 /*************************************************************************** 00002 $RCSfile: ctdatacache.h,v $ 00003 ------------------- 00004 cvs : $Id: ctdatacache.h,v 1.2 2003/01/10 20:02:12 aquamaniac Exp $ 00005 begin : Thu Apr 25 2002 00006 copyright : (C) 2002 by Martin Preuss 00007 email : martin@libchipcard.de 00008 00009 00010 *************************************************************************** 00011 * * 00012 * This library is free software; you can redistribute it and/or * 00013 * modify it under the terms of the GNU Lesser General Public * 00014 * License as published by the Free Software Foundation; either * 00015 * version 2.1 of the License, or (at your option) any later version. * 00016 * * 00017 * This library is distributed in the hope that it will be useful, * 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00020 * Lesser General Public License for more details. * 00021 * * 00022 * You should have received a copy of the GNU Lesser General Public * 00023 * License along with this library; if not, write to the Free Software * 00024 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * 00025 * MA 02111-1307 USA * 00026 * * 00027 ***************************************************************************/ 00028 00029 /* 00030 Changes 00031 00032 */ 00033 00034 00035 #ifndef CTDATACACHE_H 00036 #define CTDATACACHE_H 00037 00038 template <int SIZE, int GRANULARITY> class CHIPCARD_API CTDataCache; 00039 00040 #include <bitset> 00041 #include <string> 00042 using namespace std; 00043 00044 00050 template <int SIZE, int GRANULARITY> class CHIPCARD_API CTDataCache { 00051 private: 00052 bitset<SIZE/GRANULARITY> _valid; 00053 bitset<SIZE/GRANULARITY> _dirty; 00054 char _data[SIZE]; 00055 public: 00056 CTDataCache(){ _valid.reset(); _dirty.reset();}; 00057 ~CTDataCache(){ 00058 #if DEBUGMODE>0 00059 fprintf(stderr,"~DataCache\n"); 00060 #endif 00061 }; 00062 00063 bool isValid(unsigned int block){return _valid.test(block);}; 00064 bool isDirty(unsigned int block){ return _dirty.test(block);}; 00065 unsigned int granularity(){ return GRANULARITY;}; 00066 unsigned int size() { return SIZE;}; 00067 void setAllValid() { _valid.set();}; 00068 void setNoneValid() { _valid.reset();}; 00069 void setAllDirty() { _dirty.set();}; 00070 void setNoneDirty() { _dirty.reset();}; 00071 void setData(const string &d, unsigned int pos) { 00072 memmove(_data+pos, 00073 d.data(), 00074 d.length());}; 00075 string data(unsigned int pos, unsigned int s){ 00076 return string(_data+pos,s);}; 00077 00078 void setValid(unsigned int block) { _valid.set(block);}; 00079 void setInvalid(unsigned int block) { _valid.reset(block);}; 00080 void setDirty(unsigned int block) { _dirty.set(block);}; 00081 void setClean(unsigned int block) { _dirty.reset(block);}; 00082 }; 00083 00084 00085 #endif 00086 00087 00088

Generated on Wed Jul 28 14:56:49 2004 for libchipcard by doxygen 1.3.7