Stxxl  1.3.1
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
file Class Referenceabstract

Defines interface of file. More...

#include <file.h>

Inheritance diagram for file:
Inheritance graph
[legend]

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. More...
 
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. More...
 
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. More...
 
virtual offset_type size ()=0
 Returns size of the file. More...
 
virtual int get_queue_id () const =0
 Returns the identifier of the file's queue. More...
 
virtual int get_allocator_id () const =0
 Returns the file's allocator. More...
 
virtual int get_physical_device_id () const
 
virtual void lock ()=0
 Locks file for reading and writing (acquires a lock in the file system) More...
 
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. More...
 
virtual void export_files (offset_type offset, offset_type length, std::string prefix)
 
virtual void remove ()
 
virtual const char * io_type () const
 Identifies the type of I/O implementation. More...
 

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. More...
 

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_sizes.cpp.

Constructor & Destructor Documentation

file::file ( )
inlineprotected

Initializes file object.

Parameters
_idfile identifier
Remarks
Called in implementations of file

Member Function Documentation

virtual request_ptr 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 disk_queued_file.

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

virtual request_ptr 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 disk_queued_file.

Examples:
io/test_cancel.cpp.

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

virtual void file::discard ( offset_type  offset,
offset_type  size 
)
inlinevirtual

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

Reimplemented in fileperblock_file< base_file_type >, and mem_file.

Referenced by block_manager::delete_block().

virtual int file::get_allocator_id ( ) const
pure virtual

Returns the file's allocator.

Returns
allocator number

Implemented in disk_queued_file.

Referenced by block_manager::delete_block().

virtual int 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 disk_queued_file.

Referenced by request_with_state::cancel().

virtual const char* file::io_type ( ) const
inlinevirtual

Identifies the type of I/O implementation.

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

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

Referenced by serving_request::io_type().

virtual void file::lock ( )
pure virtual

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

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

virtual void file::set_size ( offset_type  newsize)
pure virtual

Changes the size of the file.

Parameters
newsizenew file size

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

Examples:
io/test_cancel.cpp.

Referenced by vector< Tp_, PgSz_, PgTp_, BlkSize_, AllocStr_, SzTp_ >::vector().

virtual offset_type file::size ( )
pure virtual

Returns size of the file.

Returns
file size in bytes

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


The documentation for this class was generated from the following file: