Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
file.hpp
Go to the documentation of this file.
1 /* -*- c-basic-offset: 2 -*- */
2 /* Copyright(C) 2011 Brazil
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License version 2.1 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Lesser General Public License for more details.
12 
13  You should have received a copy of the GNU Lesser General Public
14  License along with this library; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef GRN_DAT_FILE_HPP_
19 #define GRN_DAT_FILE_HPP_
20 
21 #include "dat.hpp"
22 
23 namespace grn {
24 namespace dat {
25 
26 // This implementation class hides environment dependent codes required for
27 // memory-mapped I/O.
28 class FileImpl;
29 
31  public:
32  File();
33  ~File();
34 
35  // This function creates a file and maps the entire file to a certain range
36  // of the address space. Note that a file is truncated if exists.
37  void create(const char *path, UInt64 size);
38 
39  // This function opens a file and maps the entire file to a certain range of
40  // the address space.
41  void open(const char *path);
42  void close();
43 
44  void *ptr() const;
45  UInt64 size() const;
46 
47  void swap(File *rhs);
48 
49  private:
50  FileImpl *impl_;
51 
52  // Disallows copy and assignment.
53  File(const File &);
54  File &operator=(const File &);
55 };
56 
57 } // namespace dat
58 } // namespace grn
59 
60 #endif // GRN_DAT_FILE_HPP_