WiscDB
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends
Public Member Functions | Static Public Member Functions
wiscdb::RawFile Class Reference
Inheritance diagram for wiscdb::RawFile:
wiscdb::File

List of all members.

Public Member Functions

 RawFile (const std::string &name, const bool create_new)
 RawFile (const RawFile &other)
RawFileoperator= (const RawFile &rhs)
 ~RawFile ()
Page allocatePage (PageId &new_page_number)
Page readPage (const PageId page_number) const
void writePage (const PageId page_number, const Page &new_page)
void deletePage (const PageId page_number)

Static Public Member Functions

static RawFile create (const std::string &filename)
static RawFile open (const std::string &filename)

Detailed Description

Definition at line 385 of file file.h.


Constructor & Destructor Documentation

wiscdb::RawFile::RawFile ( const std::string &  name,
const bool  create_new 
)

Constructs a file object representing a file on the filesystem.

See also:
File::create()
File::open()
Parameters:
nameName of file.
create_newWhether to create a new file.
Exceptions:
FileExistsExceptionIf the underlying file exists and create_new is true.
FileNotFoundExceptionIf the underlying file doesn't exist and create_new is false.
wiscdb::RawFile::RawFile ( const RawFile other)

Copy constructor.

Parameters:
otherFile object to copy.
Returns:
A copy of the File object.

Destructor that automatically closes the underlying file if no other File objects are using it.


Member Function Documentation

Page wiscdb::RawFile::allocatePage ( PageId new_page_number) [virtual]

Allocates a new page in the file.

Returns:
The new page.

Implements wiscdb::File.

static RawFile wiscdb::RawFile::create ( const std::string &  filename) [static]

Creates a new RawFile.

Parameters:
filenameName of the file.
Exceptions:
FileExistsExceptionIf the requested file already exists.
void wiscdb::RawFile::deletePage ( const PageId  page_number) [virtual]

Deletes a page from the file.

Parameters:
page_numberNumber of page to delete.

Implements wiscdb::File.

static RawFile wiscdb::RawFile::open ( const std::string &  filename) [static]

Opens the file named fileName and returns the corresponding File object. It first checks if the file is already open. If so, then the new File object created uses the same input-output stream to read to or write fom that already open file. Reference count (open_counts_ static variable inside the File object) is incremented whenever an already open file is opened again. Otherwise the UNIX file is actually opened. The fileName and the stream associated with this File object are inserted into the open_streams_ map.

Parameters:
filenameName of the file.
Exceptions:
FileNotFoundExceptionIf the requested file doesn't exist.
RawFile& wiscdb::RawFile::operator= ( const RawFile rhs)

Assignment operator.

Parameters:
rhsFile object to assign.
Returns:
Newly assigned file object.
Page wiscdb::RawFile::readPage ( const PageId  page_number) const [virtual]

Reads an existing page from the file.

Parameters:
page_numberNumber of page to read.
Returns:
The page.
Exceptions:
InvalidPageExceptionIf the page doesn't exist in the file or is not currently used.

Implements wiscdb::File.

void wiscdb::RawFile::writePage ( const PageId  page_number,
const Page new_page 
) [virtual]

Writes a page into the file at the given page number. No bounds checking is performed.

Parameters:
page_numberNumber of page whose contents to replace.
new_pagePage to write.

Implements wiscdb::File.


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