TPIE

2362a60
block_collection.h
1 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
2 // vi:set ts=4 sts=4 sw=4 noet cino+=(0 :
3 // Copyright 2014, The TPIE development team
4 //
5 // This file is part of TPIE.
6 //
7 // TPIE is free software: you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the
9 // Free Software Foundation, either version 3 of the License, or (at your
10 // option) any later version.
11 //
12 // TPIE is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with TPIE. If not, see <http://www.gnu.org/licenses/>
19 
23 
24 #ifndef _TPIE_BLOCKS_BLOCK_COLLECTION_H
25 #define _TPIE_BLOCKS_BLOCK_COLLECTION_H
26 
27 #include <tpie/tpie.h>
29 #include <tpie/blocks/block.h>
30 #include <tpie/blocks/freespace_collection.h>
31 
32 namespace tpie {
33 
34 namespace blocks {
35 
40 public:
47  block_collection(std::string fileName, memory_size_type blockSize, bool writeable);
48 
50 
51  block_collection(const block_collection &) = delete;
52 
58 
63  void free_block(block_handle handle);
64 
70  void read_block(block_handle handle, block & b);
71 
77  void write_block(block_handle handle, const block & b);
78 private:
79  bits::freespace_collection m_collection;
81 
82  bool m_writeable;
83 };
84 
85 } // blocks namespace
86 
87 } // tpie namespace
88 
89 #endif // _TPIE_BLOCKS_BLOCK_COLLECTION_H
tpie_init and tpie_finish.
void read_block(block_handle handle, block &b)
Reads the content of a block from disk.
A class to manage writing and reading of block to disk.
Declare default file accessor.
block_collection(std::string fileName, memory_size_type blockSize, bool writeable)
Create a block collection.
void write_block(block_handle handle, const block &b)
Writes the content of a block to disk.
block_handle get_free_block()
Allocates a new block.
void free_block(block_handle handle)
frees a block
POSIX-style file accessor.
Definition: posix.h:35