My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
store.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  *
4  *
5  * Copyright (C) 1997-2015 by Dimitri van Heesch.
6  *
7  * Permission to use, copy, modify, and distribute this software and its
8  * documentation under the terms of the GNU General Public License is hereby
9  * granted. No representations are made about the suitability of this software
10  * for any purpose. It is provided "as is" without express or implied warranty.
11  * See the GNU General Public License for more details.
12  *
13  * Documents produced by Doxygen are derivative works derived from the
14  * input used in their production; they are not affected by this license.
15  *
16  */
17 
18 #ifndef STORE_H
19 #define STORE_H
20 
21 #include <qglobal.h>
22 #include <stdio.h>
23 
24 #include "portable.h"
25 
28 {
29  public:
31  virtual ~StorageIntf() {}
33  virtual int read(char *buf,uint size) = 0;
35  virtual int write(const char *buf,uint size) = 0;
36 };
37 
52 class Store : public StorageIntf
53 {
54  public:
56  Store();
57 
59  ~Store();
60 
64  int open(const char *name);
65 
68 
73  int write(const char *buf,uint size);
74 
79  void end();
80 
82  void release(portable_off_t handle);
83 
85  void close();
86 
88  void seek(portable_off_t handle);
89 
93  int read(char *buf,uint size);
94 
95  void printStats();
96 
97  portable_off_t pos() const { return m_cur; }
98 
99  void dumpBlock(portable_off_t start,portable_off_t end);
100 
101  private:
102  enum State
103  {
107  };
108  struct Node
109  {
111  struct Node *next;
112  };
113  void printFreeList();
114  FILE *m_file;
119  int m_reads;
120  int m_writes;
121 };
122 
123 #endif