STXXL  1.4.0
 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  *
12  * Distributed under the Boost Software License, Version 1.0.
13  * (See accompanying file LICENSE_1_0.txt or copy at
14  * http://www.boost.org/LICENSE_1_0.txt)
15  **************************************************************************/
16 
17 #ifndef STXXL_IO_BOOSTFD_FILE_HEADER
18 #define STXXL_IO_BOOSTFD_FILE_HEADER
19 
20 #include <stxxl/bits/config.h>
21 
22 #ifndef STXXL_HAVE_BOOSTFD_FILE
23 #if STXXL_BOOST_CONFIG // if boost is available
24  #define STXXL_HAVE_BOOSTFD_FILE 1
25 #else
26  #define STXXL_HAVE_BOOSTFD_FILE 0
27 #endif
28 #endif
29 
30 #if STXXL_HAVE_BOOSTFD_FILE
31 
33 #include <stxxl/bits/io/request.h>
34 
35 #include <boost/iostreams/device/file_descriptor.hpp>
36 
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  mutex fd_mutex; // sequentialize function calls involving file_des
50  fd_type file_des;
51  int mode_;
52  offset_type _size();
53 
54 public:
55  boostfd_file(const std::string& filename, int mode, int queue_id = DEFAULT_QUEUE, int allocator_id = NO_ALLOCATOR);
56  ~boostfd_file();
57  offset_type size();
58  void set_size(offset_type newsize);
59  void lock();
60  void serve(const request* req) throw (io_error);
61  const char * io_type() const;
62 };
63 
64 //! \}
65 
67 
68 #endif // #if STXXL_HAVE_BOOSTFD_FILE
69 
70 #endif // !STXXL_IO_BOOSTFD_FILE_HEADER
#define STXXL_BEGIN_NAMESPACE
Definition: namespace.h:16
#define STXXL_END_NAMESPACE
Definition: namespace.h:17