1 |
/********************************************************************* |
2 |
* * |
3 |
* Copyright (c) 1997,1998, 1999 * |
4 |
* Multimedia DB Group and DEIS - CSITE-CNR, * |
5 |
* University of Bologna, Bologna, ITALY. * |
6 |
* * |
7 |
* All Rights Reserved. * |
8 |
* * |
9 |
* Permission to use, copy, and distribute this software and its * |
10 |
* documentation for NON-COMMERCIAL purposes and without fee is * |
11 |
* hereby granted provided that this copyright notice appears in * |
12 |
* all copies. * |
13 |
* * |
14 |
* THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE * |
15 |
* SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING * |
16 |
* BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, * |
17 |
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHOR * |
18 |
* SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * |
19 |
* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * |
20 |
* DERIVATIVES. * |
21 |
* * |
22 |
*********************************************************************/ |
23 |
|
24 |
#ifndef MTFILE_H |
25 |
#define MTFILE_H |
26 |
|
27 |
#include "GiSTstore.h" |
28 |
|
29 |
// MTfile is a simple storage class for GiSTs to work over |
30 |
// UNIX/NT files. It is a copy of the GiSTfile class. |
31 |
|
32 |
class MTfile: public GiSTstore { |
33 |
unsigned int page; |
34 |
struct Page { |
35 |
GiSTpage page; |
36 |
char *buf; |
37 |
int dirty; |
38 |
int seq; |
39 |
}; |
40 |
Page *cache; |
41 |
unsigned int cachesize; |
42 |
|
43 |
Page *newpage(GiSTpage page); |
44 |
Page *findpage(GiSTpage page); |
45 |
void flushpage(Page *p); |
46 |
public: |
47 |
void setcache(unsigned int pages); |
48 |
|
49 |
MTfile(unsigned int pagesize) |
50 |
: GiSTstore(), page(pagesize), cachesize(0) |
51 |
{ |
52 |
setcache (16); |
53 |
} |
54 |
|
55 |
~MTfile(); |
56 |
|
57 |
void Create(const char *filename); |
58 |
void Open(const char *filename); |
59 |
void Close(); |
60 |
|
61 |
void Read(GiSTpage page, char *buf); |
62 |
void Write(GiSTpage page, const char *buf); |
63 |
GiSTpage Allocate(); |
64 |
void Deallocate(GiSTpage page); |
65 |
void Sync(); |
66 |
int PageSize() const { return page; } |
67 |
|
68 |
private: |
69 |
int fileHandle; |
70 |
}; |
71 |
|
72 |
#endif |