00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef STXXL_FILEPERBLOCK_FILE_HEADER
00014 #define STXXL_FILEPERBLOCK_FILE_HEADER
00015
00016 #include <string>
00017 #include <stxxl/bits/io/disk_queued_file.h>
00018
00019
00020 __STXXL_BEGIN_NAMESPACE
00021
00024
00027 template <class base_file_type>
00028 class fileperblock_file : public disk_queued_file
00029 {
00030 private:
00031 std::string filename_prefix;
00032 int mode;
00033 unsigned_type current_size;
00034 bool lock_file_created;
00035 base_file_type lock_file;
00036
00037 protected:
00039 std::string filename_for_block(unsigned_type offset);
00040
00041 public:
00046 fileperblock_file(
00047 const std::string & filename_prefix,
00048 int mode,
00049 int queue_id = DEFAULT_QUEUE,
00050 int allocator_id = NO_ALLOCATOR);
00051
00052 virtual ~fileperblock_file();
00053
00054 virtual void serve(const request * req) throw (io_error);
00055
00058 virtual void set_size(offset_type new_size) { current_size = new_size; }
00059
00062 virtual offset_type size() { return current_size; }
00063
00064 virtual void lock();
00065
00068 virtual void discard(offset_type offset, offset_type length);
00069
00071 virtual void export_files(offset_type offset, offset_type length, std::string filename);
00072
00073 const char * io_type() const;
00074 };
00075
00077
00078 __STXXL_END_NAMESPACE
00079
00080 #endif // !STXXL_FILEPERBLOCK_FILE_HEADER