Stxxl  1.3.2
mem_file.h
1 /***************************************************************************
2  * include/stxxl/bits/io/mem_file.h
3  *
4  * Part of the STXXL. See http://stxxl.sourceforge.net
5  *
6  * Copyright (C) 2008 Andreas Beckmann <[email protected]>
7  * Copyright (C) 2009 Johannes Singler <[email protected]>
8  *
9  * Distributed under the Boost Software License, Version 1.0.
10  * (See accompanying file LICENSE_1_0.txt or copy at
11  * http://www.boost.org/LICENSE_1_0.txt)
12  **************************************************************************/
13 
14 #ifndef STXXL_MEM_FILE_HEADER
15 #define STXXL_MEM_FILE_HEADER
16 
17 #include <stxxl/bits/io/disk_queued_file.h>
18 #include <stxxl/bits/io/request.h>
19 
20 
21 __STXXL_BEGIN_NAMESPACE
22 
25 
27 class mem_file : public disk_queued_file
28 {
29  char * ptr;
30  offset_type sz;
31 
32 public:
36  int queue_id = DEFAULT_QUEUE, int allocator_id = NO_ALLOCATOR) : disk_queued_file(queue_id, allocator_id), ptr(NULL), sz(0)
37  { }
38  void serve(const request * req) throw (io_error);
39  ~mem_file();
40  offset_type size();
41  void set_size(offset_type newsize);
42  void lock();
43  void discard(offset_type offset, offset_type size);
44  const char * io_type() const;
45 };
46 
48 
49 __STXXL_END_NAMESPACE
50 
51 #endif // !STXXL_MEM_FILE_HEADER
Implementation of file based on new[] and memcpy.
Definition: mem_file.h:27
void set_size(offset_type newsize)
Changes the size of the file.
Definition: mem_file.cpp:63
Request with basic properties like file and offset.
Definition: request.h:39
void discard(offset_type offset, offset_type size)
Discard a region of the file (mark it unused) some specialized file types may need to know freed regi...
Definition: mem_file.cpp:70
void lock()
Locks file for reading and writing (acquires a lock in the file system)
Definition: mem_file.cpp:53
const char * io_type() const
Identifies the type of I/O implementation.
Definition: mem_file.cpp:42
offset_type size()
Returns size of the file.
Definition: mem_file.cpp:58
mem_file(int queue_id=DEFAULT_QUEUE, int allocator_id=NO_ALLOCATOR)
constructs file object
Definition: mem_file.h:35
Implementation of some file methods based on serving_request.
Definition: disk_queued_file.h:26