source: gsdl/trunk/packages/isis-gdl/CacheMan.h@ 14171

Last change on this file since 14171 was 12159, checked in by mdewsnip, 18 years ago

Fix for gcc 4?

  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1/**********************************************************************
2 *
3 * CacheMan.h
4 * Copyright (C) 2003 UNESCO
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 *********************************************************************/
25
26#ifndef __CACHEMAN_H__
27#define __CACHEMAN_H__
28
29
30#include "File.h"
31
32class CacheManager
33{
34private:
35
36 CFileBase* theFile_;
37 unsigned maxblocks_; // Max # blocks in buff_er
38 unsigned nused_; // Number being used.
39 unsigned blocksize_; // Size of a block
40 FileSystem::FAU_t* diskAddrs_; // Its disk address
41 unsigned* useCounts_; // Use count for the block
42 char* buff_; // The set of blocks.
43
44public:
45
46 CacheManager();
47 CacheManager(unsigned blocksz, unsigned mxblks);
48
49 ~CacheManager();
50
51 void Create(unsigned blocksz, unsigned mxblks = 10);
52 void Erase();
53
54 void Connect(CFileBase* file);
55 void Disconnect();
56 bool Flush(); // Perform any pending writes.
57 void Invalidate(); // Invalidate the entire cache
58 bool Read (FileSystem::FAU_t locn, void* dat);
59 bool Write(FileSystem::FAU_t locn, void* dat);
60
61private:
62
63 CacheManager(const CacheManager&); // Private to insure no copies
64 void operator=(const CacheManager&); // Ditto
65 size_t AgeAndFindSlot(FileSystem::FAU_t);
66 bool Flush(unsigned);
67 size_t GetFreeSlot();
68 size_t LRU() const; // Find least recently used block
69};
70
71#endif
Note: See TracBrowser for help on using the repository browser.