Stxxl  1.4.0
io/create_file.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002  *  io/create_file.cpp
00003  *
00004  *  Part of the STXXL. See http://stxxl.sourceforge.net
00005  *
00006  *  Copyright (C) 2002 Roman Dementiev <dementiev@mpi-sb.mpg.de>
00007  *  Copyright (C) 2008, 2010 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
00008  *  Copyright (C) 2008, 2009 Johannes Singler <singler@ira.uka.de>
00009  *
00010  *  Distributed under the Boost Software License, Version 1.0.
00011  *  (See accompanying file LICENSE_1_0.txt or copy at
00012  *  http://www.boost.org/LICENSE_1_0.txt)
00013  **************************************************************************/
00014 
00015 #include <stxxl/bits/io/create_file.h>
00016 #include <stxxl/bits/io/io.h>
00017 
00018 
00019 __STXXL_BEGIN_NAMESPACE
00020 
00021 file * create_file(const std::string & io_impl,
00022                    const std::string & filename,
00023                    int options, int physical_device_id, int allocator_id)
00024 {
00025     if (io_impl == "syscall")
00026     {
00027         ufs_file_base * result = new syscall_file(filename, options, physical_device_id, allocator_id);
00028         result->lock();
00029         return result;
00030     }
00031     else if (io_impl == "syscall_unlink")
00032     {
00033         ufs_file_base * result = new syscall_file(filename, options, physical_device_id, allocator_id);
00034         result->lock();
00035         result->unlink();
00036         return result;
00037     }
00038     else if (io_impl == "fileperblock_syscall")
00039     {
00040         fileperblock_file<syscall_file> * result = new fileperblock_file<syscall_file>(filename, options, physical_device_id, allocator_id);
00041         result->lock();
00042         return result;
00043     }
00044 #if STXXL_HAVE_MMAP_FILE
00045     else if (io_impl == "mmap")
00046     {
00047         ufs_file_base * result = new mmap_file(filename, options, physical_device_id, allocator_id);
00048         result->lock();
00049         return result;
00050     }
00051     else if (io_impl == "fileperblock_mmap")
00052     {
00053         fileperblock_file<mmap_file> * result = new fileperblock_file<mmap_file>(filename, options, physical_device_id, allocator_id);
00054         result->lock();
00055         return result;
00056     }
00057 #endif
00058 #if STXXL_HAVE_SIMDISK_FILE
00059     else if (io_impl == "simdisk")
00060     {
00061         options &= ~stxxl::file::DIRECT;  // clear the DIRECT flag, this file is supposed to be on tmpfs
00062         ufs_file_base * result = new sim_disk_file(filename, options, physical_device_id, allocator_id);
00063         result->lock();
00064         return result;
00065     }
00066 #endif
00067 #if STXXL_HAVE_WINCALL_FILE
00068     else if (io_impl == "wincall")
00069     {
00070         wfs_file_base * result = new wincall_file(filename, options, physical_device_id, allocator_id);
00071         result->lock();
00072         return result;
00073     }
00074     else if (io_impl == "fileperblock_wincall")
00075     {
00076         fileperblock_file<wincall_file> * result = new fileperblock_file<wincall_file>(filename, options, physical_device_id, allocator_id);
00077         result->lock();
00078         return result;
00079     }
00080 #endif
00081 #if STXXL_HAVE_BOOSTFD_FILE
00082     else if (io_impl == "boostfd")
00083     {
00084         boostfd_file * result = new boostfd_file(filename, options, physical_device_id, allocator_id);
00085         result->lock();
00086         return result;
00087     }
00088     else if (io_impl == "fileperblock_boostfd")
00089     {
00090         fileperblock_file<boostfd_file> * result = new fileperblock_file<boostfd_file>(filename, options, physical_device_id, allocator_id);
00091         result->lock();
00092         return result;
00093     }
00094 #endif
00095     else if (io_impl == "memory")
00096     {
00097         mem_file * result = new mem_file(physical_device_id, allocator_id);
00098         result->lock();
00099         return result;
00100     }
00101 #if STXXL_HAVE_WBTL_FILE
00102     else if (io_impl == "wbtl")
00103     {
00104         ufs_file_base * backend = new syscall_file(filename, options, -1, -1); // FIXME: ID
00105         wbtl_file * result = new stxxl::wbtl_file(backend, 16 * 1024 * 1024, 2, physical_device_id, allocator_id);
00106         result->lock();
00107         return result;
00108     }
00109 #endif
00110 
00111     STXXL_THROW(std::runtime_error, "FileCreator::create", "Unsupported disk I/O implementation " <<
00112                 io_impl << " .");
00113 
00114     return NULL;
00115 }
00116 
00117 __STXXL_END_NAMESPACE
00118 // vim: et:ts=4:sw=4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines