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

List of all members.

Public Member Functions

 PageFile (const std::string &name, const bool create_new)
 PageFile (const PageFile &other)
PageFileoperator= (const PageFile &rhs)
 ~PageFile ()
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)
FileIterator begin ()
FileIterator end ()

Static Public Member Functions

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

Friends

class FileIterator

Detailed Description

Definition at line 239 of file file.h.


Constructor & Destructor Documentation

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

Constructs a file object representing a file on the filesystem.

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.

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::PageFile::allocatePage ( PageId new_page_number) [virtual]

Allocates a new page in the file.

Returns:
The new page.

Implements wiscdb::File.

Returns an iterator at the first page in the file.

Returns:
Iterator at first page of file.
static PageFile wiscdb::PageFile::create ( const std::string &  filename) [static]

Creates a new file.

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

Deletes a page from the file.

Parameters:
page_numberNumber of page to delete.

Implements wiscdb::File.

Returns an iterator representing the page after the last page in the file. This iterator should not be dereferenced.

Returns:
Iterator representing page after the last page in the file.
static PageFile wiscdb::PageFile::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.
PageFile& wiscdb::PageFile::operator= ( const PageFile rhs)

Assignment operator.

Parameters:
rhsFile object to assign.
Returns:
Newly assigned file object.
Page wiscdb::PageFile::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::PageFile::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