STXXL  1.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mem_file.h
Go to the documentation of this file.
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  * Copyright (C) 2014 Timo Bingmann <[email protected]>
9  *
10  * Distributed under the Boost Software License, Version 1.0.
11  * (See accompanying file LICENSE_1_0.txt or copy at
12  * http://www.boost.org/LICENSE_1_0.txt)
13  **************************************************************************/
14 
15 #ifndef STXXL_IO_MEM_FILE_HEADER
16 #define STXXL_IO_MEM_FILE_HEADER
17 
19 #include <stxxl/bits/io/request.h>
20 
22 
23 //! \addtogroup fileimpl
24 //! \{
25 
26 //! Implementation of file based on new[] and memcpy.
27 class mem_file : public disk_queued_file
28 {
29  //! pointer to memory area of "file"
30  char* m_ptr;
31 
32  //! size of memory area
33  offset_type m_size;
34 
35  //! sequentialize function calls
37 
38 public:
39  //! constructs file object.
41  int queue_id = DEFAULT_QUEUE,
42  int allocator_id = NO_ALLOCATOR,
43  unsigned int device_id = DEFAULT_DEVICE_ID)
44  : file(device_id),
45  disk_queued_file(queue_id, allocator_id),
46  m_ptr(NULL), m_size(0)
47  { }
48  void serve(void* buffer, offset_type offset, size_type bytes,
50  ~mem_file();
51  offset_type size();
52  void set_size(offset_type newsize);
53  void lock();
54  void discard(offset_type offset, offset_type size);
55  const char * io_type() const;
56 };
57 
58 //! \}
59 
61 
62 #endif // !STXXL_IO_MEM_FILE_HEADER
char * m_ptr
pointer to memory area of &quot;file&quot;
Definition: mem_file.h:30
mem_file(int queue_id=DEFAULT_QUEUE, int allocator_id=NO_ALLOCATOR, unsigned int device_id=DEFAULT_DEVICE_ID)
constructs file object.
Definition: mem_file.h:40
Defines interface of file.
Definition: file.h:56
#define STXXL_BEGIN_NAMESPACE
Definition: namespace.h:16
Implementation of some file methods based on serving_request.
mutex m_mutex
sequentialize function calls
Definition: mem_file.h:36
offset_type m_size
size of memory area
Definition: mem_file.h:33
Implementation of file based on new[] and memcpy.
Definition: mem_file.h:27
static const size_t bytes
number of bytes in uint_pair
Definition: uint_types.h:96
void discard(StreamAlgorithm &in)
Reads stream content and discards it. Useful where you do not need the processed stream anymore...
Definition: stream.h:640
#define STXXL_END_NAMESPACE
Definition: namespace.h:17