Stxxl  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes
stxxl::file Class Reference

Defines interface of file. More...

#include <file.h>

Inheritance diagram for stxxl::file:
Inheritance graph
[legend]
Collaboration diagram for stxxl::file:
Collaboration graph
[legend]

List of all members.

Public Types

enum  open_mode {
  RDONLY = 1, WRONLY = 2, RDWR = 4, CREAT = 8,
  DIRECT = 16, TRUNC = 32, SYNC = 64, NO_LOCK = 128
}
 Definition of acceptable file open modes. More...
typedef request::offset_type offset_type
typedef request::size_type size_type

Public Member Functions

virtual request_ptr aread (void *buffer, offset_type pos, size_type bytes, const completion_handler &on_cmpl)=0
 Schedules an asynchronous read request to the file.
virtual request_ptr awrite (void *buffer, offset_type pos, size_type bytes, const completion_handler &on_cmpl)=0
 Schedules an asynchronous write request to the file.
virtual void serve (const request *req)=0 throw (io_error)
void add_request_ref ()
void delete_request_ref ()
int get_request_nref ()
virtual void set_size (offset_type newsize)=0
 Changes the size of the file.
virtual offset_type size ()=0
 Returns size of the file.
virtual int get_queue_id () const =0
 Returns the identifier of the file's queue.
virtual int get_allocator_id () const =0
 Returns the file's allocator.
virtual int get_physical_device_id () const
virtual void lock ()=0
 Locks file for reading and writing (acquires a lock in the file system)
virtual void discard (offset_type offset, offset_type size)
 Discard a region of the file (mark it unused) some specialized file types may need to know freed regions.
virtual void export_files (offset_type offset, offset_type length, std::string prefix)
virtual void remove ()
virtual ~file ()
virtual const char * io_type () const
 Identifies the type of I/O implementation.

Static Public Attributes

static const int DEFAULT_QUEUE = -1
static const int NO_QUEUE = -2
static const int NO_ALLOCATOR = -1

Protected Member Functions

 file ()
 Initializes file object.

Private Attributes

mutex request_ref_cnt_mutex
int request_ref_cnt

Detailed Description

Defines interface of file.

It is a base class for different implementations that might base on various file systems or even remote storage interfaces

Examples:
io/test_cancel.cpp, and io/test_io.cpp.

Definition at line 90 of file file.h.


Member Typedef Documentation

Definition at line 103 of file file.h.

Definition at line 105 of file file.h.


Member Enumeration Documentation

Definition of acceptable file open modes.

Various open modes in a file system must be converted to this set of acceptable modes

Enumerator:
RDONLY 

only reading of the file is allowed

WRONLY 

only writing of the file is allowed

RDWR 

read and write of the file are allowed

CREAT 

in case file does not exist no error occurs and file is newly created

DIRECT 

I/Os proceed bypassing file system buffers, i.e. unbuffered I/O.

TRUNC 

once file is opened its length becomes zero

SYNC 

open the file with O_SYNC | O_DSYNC | O_RSYNC flags set

NO_LOCK 

do not aquire an exclusive lock by default

Definition at line 111 of file file.h.


Constructor & Destructor Documentation

stxxl::file::file ( ) [inline, protected]

Initializes file object.

Parameters:
_idfile identifier
Remarks:
Called in implementations of file

Definition at line 99 of file file.h.

virtual stxxl::file::~file ( ) [inline, virtual]

Definition at line 205 of file file.h.


Member Function Documentation

void stxxl::file::add_request_ref ( ) [inline]

Definition at line 147 of file file.h.

Referenced by stxxl::request::request().

virtual request_ptr stxxl::file::aread ( void *  buffer,
offset_type  pos,
size_type  bytes,
const completion_handler on_cmpl 
) [pure virtual]

Schedules an asynchronous read request to the file.

Parameters:
bufferpointer to memory buffer to read into
posfile position to start read from
bytesnumber of bytes to transfer
on_cmplI/O completion handler
Returns:
request_ptr request object, which can be used to track the status of the operation

Implemented in stxxl::disk_queued_file.

Referenced by stxxl::typed_block< RawSize_, T_, NRef_, InfoType_ >::read(), and run().

virtual request_ptr stxxl::file::awrite ( void *  buffer,
offset_type  pos,
size_type  bytes,
const completion_handler on_cmpl 
) [pure virtual]

Schedules an asynchronous write request to the file.

Parameters:
bufferpointer to memory buffer to write from
posstarting file position to write
bytesnumber of bytes to transfer
on_cmplI/O completion handler
Returns:
request_ptr request object, which can be used to track the status of the operation

Implemented in stxxl::disk_queued_file.

Referenced by stxxl::typed_block< RawSize_, T_, NRef_, InfoType_ >::write().

Definition at line 153 of file file.h.

Referenced by stxxl::request::completed().

virtual void stxxl::file::discard ( offset_type  offset,
offset_type  size 
) [inline, virtual]

Discard a region of the file (mark it unused) some specialized file types may need to know freed regions.

Reimplemented in stxxl::fileperblock_file< base_file_type >, and stxxl::mem_file.

Definition at line 190 of file file.h.

virtual void stxxl::file::export_files ( offset_type  offset,
offset_type  length,
std::string  prefix 
) [inline, virtual]

Reimplemented in stxxl::fileperblock_file< base_file_type >.

Definition at line 196 of file file.h.

virtual int stxxl::file::get_allocator_id ( ) const [pure virtual]

Returns the file's allocator.

Returns:
allocator number

Implemented in stxxl::disk_queued_file.

Referenced by stxxl::block_manager::delete_block(), stxxl::block_manager::new_blocks_int(), and stxxl::serving_request::serve().

virtual int stxxl::file::get_physical_device_id ( ) const [inline, virtual]

Definition at line 180 of file file.h.

virtual int stxxl::file::get_queue_id ( ) const [pure virtual]

Returns the identifier of the file's queue.

Remarks:
Files allocated on the same physical device usually share the same queue
Returns:
queue number

Implemented in stxxl::disk_queued_file.

Definition at line 160 of file file.h.

virtual const char* stxxl::file::io_type ( ) const [inline, virtual]

Identifies the type of I/O implementation.

Returns:
pointer to null terminated string of characters, containing the name of I/O implementation

Reimplemented in stxxl::sim_disk_file, stxxl::wbtl_file, stxxl::fileperblock_file< base_file_type >, stxxl::mmap_file, stxxl::ufs_file_base, stxxl::mem_file, and stxxl::syscall_file.

Definition at line 214 of file file.h.

Referenced by stxxl::serving_request::io_type().

virtual void stxxl::file::lock ( ) [pure virtual]

Locks file for reading and writing (acquires a lock in the file system)

Implemented in stxxl::wbtl_file, stxxl::fileperblock_file< base_file_type >, stxxl::ufs_file_base, and stxxl::mem_file.

virtual void stxxl::file::remove ( ) [inline, virtual]

Reimplemented in stxxl::ufs_file_base.

Definition at line 203 of file file.h.

virtual void stxxl::file::serve ( const request req) throw (io_error) [pure virtual]
virtual void stxxl::file::set_size ( offset_type  newsize) [pure virtual]

Changes the size of the file.

Parameters:
newsizenew file size

Implemented in stxxl::sim_disk_file, stxxl::fileperblock_file< base_file_type >, stxxl::ufs_file_base, and stxxl::mem_file.

Referenced by main(), and stxxl::vector< ValueType >::vector().

virtual offset_type stxxl::file::size ( ) [pure virtual]

Returns size of the file.

Returns:
file size in bytes

Implemented in stxxl::wbtl_file, stxxl::fileperblock_file< base_file_type >, stxxl::ufs_file_base, and stxxl::mem_file.


Member Data Documentation

const int stxxl::file::DEFAULT_QUEUE = -1 [static]

Definition at line 123 of file file.h.

const int stxxl::file::NO_ALLOCATOR = -1 [static]

Definition at line 125 of file file.h.

const int stxxl::file::NO_QUEUE = -2 [static]

Definition at line 124 of file file.h.

Definition at line 93 of file file.h.

Definition at line 92 of file file.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines