Back to index

texmacs  1.0.7.15
disk_table.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : disk_table.hpp
00004 * DESCRIPTION: large size tables stored on disk
00005 * COPYRIGHT  : (C) 2007  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef DISK_TABLE_H
00013 #define DISK_TABLE_H
00014 #include "url.hpp"
00015 #include "hashmap.hpp"
00016 #include "iterator.hpp"
00017 #include <stdio.h>
00018 
00019 typedef hashmap<string,int> collection;
00020 typedef hashmap<string,collection> transaction;
00021 
00022 class disk_table_rep: concrete_struct {
00023 private:
00024   url         root;           // directory where the table is stored
00025   FILE*       pending_fp;     // file pointer for pending writes
00026   transaction pending_write;  // pending transactions for writing
00027   transaction pending_read;   // pending transactions for caching
00028   transaction read_cache;     // cache for reading
00029 
00030 private:
00031   void open_pending_write ();
00032   void close_pending_write ();
00033   void flush_pending_write ();
00034   void flush_pending_read ();
00035 
00036 public:
00037   disk_table_rep (url root2);
00038   ~disk_table_rep ();
00039   void write (transaction t);
00040   transaction read (collection keys);
00041   friend class disk_table;
00042 };
00043 
00044 class disk_table {
00045 CONCRETE_NULL(disk_table);
00046   inline disk_table (url u):
00047     rep (tm_new<disk_table_rep> (u)) {}
00048 };
00049 CONCRETE_NULL_CODE(disk_table);
00050 
00051 #endif // defined DISK_TABLE_H