STXXL  1.4-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
boostfd_file.h
Go to the documentation of this file.
1 /***************************************************************************
2  * include/stxxl/bits/io/boostfd_file.h
3  *
4  * File implementation based on boost::iostreams::file_decriptor
5  *
6  * Part of the STXXL. See http://stxxl.sourceforge.net
7  *
8  * Copyright (C) 2006 Roman Dementiev <[email protected]>
9  * Copyright (C) 2008 Andreas Beckmann <[email protected]>
10  * Copyright (C) 2009 Johannes Singler <[email protected]>
11  * Copyright (C) 2014 Timo Bingmann <[email protected]>
12  *
13  * Distributed under the Boost Software License, Version 1.0.
14  * (See accompanying file LICENSE_1_0.txt or copy at
15  * http://www.boost.org/LICENSE_1_0.txt)
16  **************************************************************************/
17 
18 #ifndef STXXL_IO_BOOSTFD_FILE_HEADER
19 #define STXXL_IO_BOOSTFD_FILE_HEADER
20 
21 #include <stxxl/bits/config.h>
22 
23 #ifndef STXXL_HAVE_BOOSTFD_FILE
24 #if STXXL_BOOST_CONFIG // if boost is available
25  #define STXXL_HAVE_BOOSTFD_FILE 1
26 #else
27  #define STXXL_HAVE_BOOSTFD_FILE 0
28 #endif
29 #endif
30 
31 #if STXXL_HAVE_BOOSTFD_FILE
32 
34 #include <stxxl/bits/io/request.h>
35 
36 #include <boost/iostreams/device/file_descriptor.hpp>
37 
39 
40 //! \addtogroup fileimpl
41 //! \{
42 
43 //! Implementation based on boost::iostreams::file_decriptor.
44 class boostfd_file : public disk_queued_file
45 {
46  typedef boost::iostreams::file_descriptor fd_type;
47 
48 protected:
49  //! sequentialize function calls involving m_file_des
50  mutex m_fd_mutex;
51  fd_type m_file_des;
52  int m_mode;
53  offset_type _size();
54 
55 public:
56  boostfd_file(
57  const std::string& filename, int mode,
58  int queue_id = DEFAULT_QUEUE,
59  int allocator_id = NO_ALLOCATOR,
60  unsigned int device_id = DEFAULT_DEVICE_ID);
61  ~boostfd_file();
62  offset_type size();
63  void set_size(offset_type newsize);
64  void lock();
65  void serve(void* buffer, offset_type offset, size_type bytes,
66  request::request_type type);
67  const char * io_type() const;
68 };
69 
70 //! \}
71 
73 
74 #endif // #if STXXL_HAVE_BOOSTFD_FILE
75 
76 #endif // !STXXL_IO_BOOSTFD_FILE_HEADER
#define STXXL_BEGIN_NAMESPACE
Definition: namespace.h:16
static const size_t bytes
number of bytes in uint_pair
Definition: uint_types.h:96
#define STXXL_END_NAMESPACE
Definition: namespace.h:17