MASA-Core
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
SpecialRow Class Reference

Detailed Description

Abstract class that represents an Special Row.

A Special Row is a row (or column) stored to be used in the further stages. This class permit that subclasses store the special row in any possible area (e.g.: disk, memory, database, etc.).

Definition at line 41 of file SpecialRow.hpp.

#include <SpecialRow.hpp>

Inheritance diagram for SpecialRow:
SeekableCellsReader CellsWriter CellsReader FirstRow SpecialRowFile SpecialRowRAM

List of all members.

Public Member Functions

 SpecialRow ()
 Default Constructor.
virtual ~SpecialRow ()
 Default Destructor.
void open (bool readOnly, int length=0)
 Opens the special rows for read-only or write-only.
virtual int write (const cell_t *buf, int len)
 Writes data in the row serially.
virtual int read (cell_t *buf, int len)
 Reads data from the row serially.
virtual int getType ()
void seek (int offset)
 Defines the next position to be read.
int getOffset ()
 Returns the current reading position.
int getId ()
 Returns the ID of the row.
virtual void close ()=0
 Closes the special row for writing.
virtual void truncateRow (int size)=0
 Truncate the size of the row.

Static Public Member Functions

static int sortById (SpecialRow *a, SpecialRow *b)
 Function that sorts the special rows by ID.

Protected Member Functions

void setId (int id)
 Defines the ID of the row, i.e., the number of the row it represents.

Private Member Functions

virtual void initialize (bool readOnly, int length=0)=0
 Initializes the row with specific data.
virtual int write (const cell_t *buf, int offset, int len)=0
 Stores the vector in a given offset.
virtual int read (cell_t *buf, int offset, int len)=0
 Stores the vector in a given offset.

Private Attributes

int id
 The number of the row that this object represents.
int offset
 Current reading position.
bool readOnly
 Indicates if the row is in reading or writing mode.

Constructor & Destructor Documentation

Default Constructor.

Definition at line 29 of file SpecialRow.cpp.

SpecialRow::~SpecialRow ( ) [virtual]

Default Destructor.

Definition at line 36 of file SpecialRow.cpp.


Member Function Documentation

virtual void SpecialRow::close ( ) [pure virtual]

Closes the special row for writing.

Implements CellsWriter.

Implemented in SpecialRowFile, FirstRow, and SpecialRowRAM.

Returns the ID of the row.

Returns:
the number of the row (i-coordinate).

Definition at line 62 of file SpecialRow.cpp.

int SpecialRow::getOffset ( ) [virtual]

Returns the current reading position.

Returns:
the index of the next cell to be read.

Implements SeekableCellsReader.

Definition at line 92 of file SpecialRow.cpp.

int SpecialRow::getType ( ) [virtual]

Implements CellsReader.

Definition at line 48 of file SpecialRow.cpp.

virtual void SpecialRow::initialize ( bool  readOnly,
int  length = 0 
) [private, pure virtual]

Initializes the row with specific data.

Parameters:
readOnlyif true, indicates that the row will be used only for read access. Otherwise, the row will only be used for write access. Each subclass must implement this method with specific code.
lengththe maximum length of this row. The subclass may consider this as the initial size, for faster allocation.

Implemented in FirstRow, SpecialRowFile, and SpecialRowRAM.

void SpecialRow::open ( bool  readOnly,
int  length = 0 
)

Opens the special rows for read-only or write-only.

Parameters:
readOnlyif true, indicates that the row will be used only for read access. Otherwise, the row will only be used for write access.
lengththe maximum length of this row.

Definition at line 43 of file SpecialRow.cpp.

int SpecialRow::read ( cell_t buf,
int  len 
) [virtual]

Reads data from the row serially.

The read access is done in the reverse direction, from the end to the beginning. Before reading, the SpecialRow::setOffset must defines the start position to be read.

Parameters:
bufvector that will receive the cells read from the row.
lenlength of the vector.
Returns:
The number of cells read.

Implements CellsReader.

Definition at line 119 of file SpecialRow.cpp.

virtual int SpecialRow::read ( cell_t buf,
int  offset,
int  len 
) [private, pure virtual]

Stores the vector in a given offset.

It is guaranteed that the offset is serially decremented. Each subclass must implement this method with specific code.

Parameters:
bufvector containing the cells to be read. The data read will be stored in the first byte of this vector.
offsetthe position that the data must be read.
lenlength of the vector.
Returns:
The number of cells read.

Implemented in FirstRow, SpecialRowFile, and SpecialRowRAM.

void SpecialRow::seek ( int  offset) [virtual]

Defines the next position to be read.

Parameters:
offsetThe reading position.

Implements SeekableCellsReader.

Definition at line 81 of file SpecialRow.cpp.

void SpecialRow::setId ( int  id) [protected]

Defines the ID of the row, i.e., the number of the row it represents.

Parameters:
idthe number of the row (i-coordinate).

Definition at line 55 of file SpecialRow.cpp.

int SpecialRow::sortById ( SpecialRow a,
SpecialRow b 
) [static]

Function that sorts the special rows by ID.

Definition at line 69 of file SpecialRow.cpp.

virtual void SpecialRow::truncateRow ( int  size) [pure virtual]

Truncate the size of the row.

If the size is zero, the row must be completely deleted. Each subclass must implement this method with specific code.

Parameters:
sizethe number of cells to keep after truncation.

Implemented in SpecialRowFile, FirstRow, and SpecialRowRAM.

int SpecialRow::write ( const cell_t buf,
int  len 
) [virtual]

Writes data in the row serially.

Parameters:
bufvector containing the cells to be appended to the row.
lenlength of the vector.
Returns:
The number of cells written.

Implements CellsWriter.

Definition at line 99 of file SpecialRow.cpp.

virtual int SpecialRow::write ( const cell_t buf,
int  offset,
int  len 
) [private, pure virtual]

Stores the vector in a given offset.

It is guaranteed that the offset is serially incremented. Each subclass must implement this method with specific code.

Parameters:
bufvector containing the cells to be saved.
offsetthe position that the vector must be stored.
lenlength of the vector.
Returns:
The number of cells stored.

Implemented in FirstRow, SpecialRowFile, and SpecialRowRAM.


Member Data Documentation

int SpecialRow::id [private]

The number of the row that this object represents.

Definition at line 134 of file SpecialRow.hpp.

int SpecialRow::offset [private]

Current reading position.

Definition at line 137 of file SpecialRow.hpp.

bool SpecialRow::readOnly [private]

Indicates if the row is in reading or writing mode.

Definition at line 140 of file SpecialRow.hpp.


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