Stxxl
1.4.0
|
00001 /*************************************************************************** 00002 * include/stxxl/bits/io/boostfd_file.h 00003 * 00004 * File implementation based on boost::iostreams::file_decriptor 00005 * 00006 * Part of the STXXL. See http://stxxl.sourceforge.net 00007 * 00008 * Copyright (C) 2006 Roman Dementiev <dementiev@ira.uka.de> 00009 * Copyright (C) 2008 Andreas Beckmann <beckmann@cs.uni-frankfurt.de> 00010 * Copyright (C) 2009 Johannes Singler <singler@ira.uka.de> 00011 * 00012 * Distributed under the Boost Software License, Version 1.0. 00013 * (See accompanying file LICENSE_1_0.txt or copy at 00014 * http://www.boost.org/LICENSE_1_0.txt) 00015 **************************************************************************/ 00016 00017 #ifndef STXXL_BOOSTFD_FILE_H_ 00018 #define STXXL_BOOSTFD_FILE_H_ 00019 00020 #ifndef STXXL_HAVE_BOOSTFD_FILE 00021 #ifdef STXXL_BOOST_CONFIG // if boost is available 00022 #define STXXL_HAVE_BOOSTFD_FILE 1 00023 #else 00024 #define STXXL_HAVE_BOOSTFD_FILE 0 00025 #endif 00026 #endif 00027 00028 #if STXXL_HAVE_BOOSTFD_FILE 00029 00030 #include <stxxl/bits/io/disk_queued_file.h> 00031 #include <stxxl/bits/io/request.h> 00032 00033 #include <boost/iostreams/device/file_descriptor.hpp> 00034 00035 00036 __STXXL_BEGIN_NAMESPACE 00037 00038 //! \addtogroup fileimpl 00039 //! \{ 00040 00041 //! \brief Implementation based on boost::iostreams::file_decriptor 00042 class boostfd_file : public disk_queued_file 00043 { 00044 typedef boost::iostreams::file_descriptor fd_type; 00045 00046 protected: 00047 mutex fd_mutex; // sequentialize function calls involving file_des 00048 fd_type file_des; 00049 int mode_; 00050 offset_type _size(); 00051 00052 public: 00053 boostfd_file(const std::string & filename, int mode, int queue_id = DEFAULT_QUEUE, int allocator_id = NO_ALLOCATOR); 00054 ~boostfd_file(); 00055 offset_type size(); 00056 void set_size(offset_type newsize); 00057 void lock(); 00058 void serve(const request * req) throw (io_error); 00059 const char * io_type() const; 00060 }; 00061 00062 //! \} 00063 00064 __STXXL_END_NAMESPACE 00065 00066 #endif // #if STXXL_HAVE_BOOSTFD_FILE 00067 00068 #endif // !STXXL_BOOSTFD_FILE_H_