Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

OmgClimateFileReader Class Reference
[Library]

#include <omgclimatefilereader.h>

Inheritance diagram for OmgClimateFileReader:

Inheritance graph
[legend]
Collaboration diagram for OmgClimateFileReader:

Collaboration graph
[legend]
List of all members.

Detailed Description

This class will handle opening a file containing a climate matrix and iterating through the file in a columnwise / rowwise manner.

Definition at line 37 of file omgclimatefilereader.h.

Public Types

enum  FileType {
  GDAL, HADLEY_SRES, HADLEY_IS92, HADLEY_SRES_MEAN,
  IPCC_OBSERVED, VALDES, ECHAM4, CSIRO_MK2,
  NCAR_CSM_PCM, GFDL_R30, CGCM2, CCSR_AGCM_OGCM,
  CRU_CL1_MONTHLY
}

Signals

void error (QString theError)
void message (QString theMessage)

Public Member Functions

 OmgClimateFileReader ()
 OmgClimateFileReader (QString theFileName, FileType theFileType)
 ~OmgClimateFileReader ()
bool initialise (QString theFileNameString, FileType theFileType)
float getElement ()
const long currentElementNo ()
const long currentRow ()
const long currentCol ()
const int headerLineCount ()
bool setActiveBlock (const unsigned int theBlockNo)
const int activeBlock ()
const bool isAtMatrixEnd ()
const QString filename ()
const OmgClimateFileReader::FileType getFileType ()
const long yDim ()
const long xDim ()
const int blockHeaderLineCount ()
QString getOmgClimateFileReaderInfo ()
const int blockStartPos ()
bool moveToHeader ()
const int blockCount ()
int getNumberOfBlocks ()
void printFirstCellInEachBlock ()
void printLastCellInEachBlock ()
void printBlockMarkers ()
void printBlock (int theBlock)

Private Member Functions

bool setFileType (const FileType theNewVal)
QVector< int > getBlockMarkers (bool forceFlag=false)
double readValue (void *theData, GDALDataType theType, int theIndex)

Private Attributes

unsigned int mXDim
unsigned int mYDim
FileType mFileType
QString mFileName
bool mEndOfMatrixFlag
int mActiveBlockNo
int mFileHeaderLines
unsigned int mCurrentColumn
unsigned int mCurrentRow
unsigned int mCurrentElementNo
std::ifstream mTextStream
char mBuffer [mMaxLineLength]
GDALDataset * mGdalDataset
int mBlockHeaderLines
int mBlockStartPos
QVector< int > mBlockMarkersVector

Static Private Attributes

static const unsigned int mMaxLineLength = 100


Member Enumeration Documentation

enum OmgClimateFileReader::FileType
 

This enum defines the different types of files that can be read in.

Enumeration values:
GDAL 
HADLEY_SRES 
HADLEY_IS92 
HADLEY_SRES_MEAN 
IPCC_OBSERVED 
VALDES 
ECHAM4 
CSIRO_MK2 
NCAR_CSM_PCM 
GFDL_R30 
CGCM2 
CCSR_AGCM_OGCM 
CRU_CL1_MONTHLY 

Definition at line 49 of file omgclimatefilereader.h.


Constructor & Destructor Documentation

OmgClimateFileReader::OmgClimateFileReader  ) 
 

Default constructor

Definition at line 29 of file omgclimatefilereader.cpp.

OmgClimateFileReader::OmgClimateFileReader QString  theFileName,
FileType  theFileType
 

Constructor (default ctor is in private section to stop progrmmers using it!)

Definition at line 32 of file omgclimatefilereader.cpp.

References initialise().

Here is the call graph for this function:

OmgClimateFileReader::~OmgClimateFileReader  ) 
 

Destructor

Definition at line 39 of file omgclimatefilereader.cpp.

References GDAL, mFileType, mGdalDataset, and mTextStream.


Member Function Documentation

const int OmgClimateFileReader::activeBlock  ) 
 

Accessor of int mActiveBlockNo. This is really only applicable for file formats that include muliple months / years data in a single file such as Hadley SRES data.

Returns:
bool - flag indicating success or failure

Definition at line 241 of file omgclimatefilereader.cpp.

References mActiveBlockNo.

const int OmgClimateFileReader::blockCount  ) 
 

The number of blocks available in this file.

Definition at line 590 of file omgclimatefilereader.cpp.

References mBlockMarkersVector.

Referenced by OmgClimateImporter::import().

const int OmgClimateFileReader::blockHeaderLineCount  ) 
 

Read property of int mBlockHeaderLines.

Definition at line 306 of file omgclimatefilereader.cpp.

References mBlockHeaderLines.

const int OmgClimateFileReader::blockStartPos  ) 
 

Read property of blockStartPos.

Definition at line 311 of file omgclimatefilereader.cpp.

References mBlockStartPos.

const long OmgClimateFileReader::currentCol  ) 
 

Accessor property of long mCurrentColumn.

Returns:
long - the current row position in the current block.

Definition at line 286 of file omgclimatefilereader.cpp.

References mCurrentColumn.

Referenced by OmgRasterThreshold::accept(), OmgClimateImporter::import(), and printBlock().

const long OmgClimateFileReader::currentElementNo  ) 
 

Accessor for long mCurrentElementNo. Calculated as (currentRowLong * rows) + mCurrentColumn.

Returns:
long - the current position in the current block.

Definition at line 300 of file omgclimatefilereader.cpp.

References mCurrentElementNo.

const long OmgClimateFileReader::currentRow  ) 
 

Accessor property of long currentRowLong.

Returns:
long - the current row position in the current block.

Definition at line 293 of file omgclimatefilereader.cpp.

References mCurrentRow.

Referenced by OmgRasterThreshold::accept(), and OmgClimateImporter::import().

void OmgClimateFileReader::error QString  theError  )  [signal]
 

Referenced by getBlockMarkers(), getElement(), initialise(), and setActiveBlock().

const QString OmgClimateFileReader::filename  ) 
 

Accessor for QString Filename.

Returns:
QString - the current filename

Definition at line 226 of file omgclimatefilereader.cpp.

References mFileName.

QVector< int > OmgClimateFileReader::getBlockMarkers bool  forceFlag = false  )  [private]
 

Use the header info for a given file type to determine the begining of the data block(s) and position the blockStartPos there. This method will need to be called explicitly by the client app so that when multiple copies of the same file are being opened, we dont need to do the same thing each time.

Parameters:
forceFlag - Force parsing file for block markers. By default this is set to false and the file will only be parsed if an accompanying .bmr file is found.
Returns:
QVector <int> - a qvalue vector contining a series of file offsets (ulongs) which mark the start of each data block.

Definition at line 319 of file omgclimatefilereader.cpp.

References error(), GDAL, mBlockHeaderLines, mBlockMarkersVector, mBuffer, mCurrentColumn, mCurrentElementNo, mCurrentRow, message(), mFileHeaderLines, mFileName, mFileType, mMaxLineLength, mTextStream, mXDim, and mYDim.

Referenced by initialise().

float OmgClimateFileReader::getElement  ) 
 

*Get the next available element from the file matrix. *The cell index will be advanced by one.

Returns:
float - the value at the element at the next cell.

Definition at line 471 of file omgclimatefilereader.cpp.

References error(), GDAL, mCurrentColumn, mCurrentElementNo, mCurrentRow, mEndOfMatrixFlag, mFileType, mGdalDataset, mTextStream, mXDim, mYDim, and readValue().

Referenced by OmgRasterThreshold::accept(), OmgClimateFileGroup::getElementVector(), OmgClimateImporter::import(), printBlock(), printFirstCellInEachBlock(), and printLastCellInEachBlock().

Here is the call graph for this function:

const OmgClimateFileReader::FileType OmgClimateFileReader::getFileType  ) 
 

Read property of FileTypeEnum fileType.

Note:
The return type is OmgClimateFileReader::FileTypeEnum because the calling class does not have the enum in its name space so we need to. explicitly specifiy the namespace.
Returns:
OmgClimateFileReader::FileTypeEnum - the file format of the current file.

Definition at line 103 of file omgclimatefilereader.cpp.

References mFileType.

int OmgClimateFileReader::getNumberOfBlocks  ) 
 

Find out how many blocks (useful in multiblock formats such as SRES) are in this file.

QString OmgClimateFileReader::getOmgClimateFileReaderInfo  ) 
 

Return the various metadata stored for the open file.

const int OmgClimateFileReader::headerLineCount  ) 
 

Accessor for the int mFileHeaderLines.

Returns:
int - the number of header lines before each block

Definition at line 280 of file omgclimatefilereader.cpp.

References mFileHeaderLines.

bool OmgClimateFileReader::initialise QString  theFileNameString,
FileType  theFileType
 

Setup the file reader

Parameters:
theFileNameString the name of the file to be read
theFileType the file format to be read
Returns:
bool true on success

Definition at line 52 of file omgclimatefilereader.cpp.

References error(), GDAL, getBlockMarkers(), mCurrentColumn, mCurrentElementNo, mCurrentRow, mEndOfMatrixFlag, mFileName, mGdalDataset, mTextStream, and setFileType().

Referenced by OmgClimateImporter::import(), OmgClimateDataProcessorController::initialiseFileGroup(), and OmgClimateFileReader().

Here is the call graph for this function:

const bool OmgClimateFileReader::isAtMatrixEnd  ) 
 

Accessor for bool endOfMatrixFlag.

Returns:
bool - Current state of endOfMatrixFlag

Definition at line 235 of file omgclimatefilereader.cpp.

References mEndOfMatrixFlag.

Referenced by OmgRasterThreshold::accept(), OmgClimateFileGroup::getElementVector(), OmgClimateImporter::import(), printBlock(), and printLastCellInEachBlock().

void OmgClimateFileReader::message QString  theMessage  )  [signal]
 

Referenced by getBlockMarkers().

bool OmgClimateFileReader::moveToHeader  ) 
 

Move the internal file pointer to the start of the file header.

void OmgClimateFileReader::printBlock int  theBlock  ) 
 

A helper function to show a whole block.

Note:
This will likely be removed!

Definition at line 631 of file omgclimatefilereader.cpp.

References currentCol(), getElement(), isAtMatrixEnd(), and setActiveBlock().

Here is the call graph for this function:

void OmgClimateFileReader::printBlockMarkers  ) 
 

A helper function to see if the block markers are correct. The value of each block marker file seek position will be printed.

Returns:
void - No return.

Definition at line 622 of file omgclimatefilereader.cpp.

References mBlockMarkersVector.

void OmgClimateFileReader::printFirstCellInEachBlock  ) 
 

A helper function to see if the block markers are correct. The value of the first element in each block will be printed to console on std out.

Returns:
void - No return.

Definition at line 595 of file omgclimatefilereader.cpp.

References getElement(), mBlockMarkersVector, and setActiveBlock().

Here is the call graph for this function:

void OmgClimateFileReader::printLastCellInEachBlock  ) 
 

A helper function to see if the block markers are correct. The value of the last element in each block will be printed to console on std out.

Returns:
void - No return.

Definition at line 606 of file omgclimatefilereader.cpp.

References getElement(), isAtMatrixEnd(), mBlockMarkersVector, and setActiveBlock().

Here is the call graph for this function:

double OmgClimateFileReader::readValue void *  theData,
GDALDataType  theType,
int  theIndex
[private]
 

A helper method for gdal reading to get a value into the correct type.

Parameters:
theData a scanline of data from gdal.
theType the gdal datatype of data in this scanline
theIndex Postion inthe scanline to read from.
Returns:
float containing the value we read in

Definition at line 557 of file omgclimatefilereader.cpp.

Referenced by getElement().

bool OmgClimateFileReader::setActiveBlock const unsigned int  theBlockNo  ) 
 

Mutator for int mActiveBlockNo. It will move the file pointer too the start of the data block indicated by the start month. This is really only applicable for file formats that include muliple months / years data in a single file such as Hadley SRES data.

Parameters:
theNewVal - an unsigned int representing the new start block.
Returns:
bool - flag indicating success or failure

Definition at line 247 of file omgclimatefilereader.cpp.

References error(), mActiveBlockNo, mBlockMarkersVector, mBlockStartPos, mCurrentColumn, mCurrentElementNo, mCurrentRow, mEndOfMatrixFlag, and mTextStream.

Referenced by OmgClimateImporter::import(), OmgClimateDataProcessorController::initialiseFileGroup(), printBlock(), printFirstCellInEachBlock(), printLastCellInEachBlock(), and OmgClimateFileGroup::rewind().

bool OmgClimateFileReader::setFileType const FileType  theNewVal  )  [private]
 

Mutator of FileTypeEnum fileType.

Note:
You should specify the file type BEFORE opening the file.
Parameters:
theNewVal - a FileTypeEnum specifying the input file type.
Returns:
bool - flag indicating success or failure

Definition at line 110 of file omgclimatefilereader.cpp.

References CCSR_AGCM_OGCM, CGCM2, CRU_CL1_MONTHLY, CSIRO_MK2, ECHAM4, GDAL, GFDL_R30, HADLEY_IS92, HADLEY_SRES, HADLEY_SRES_MEAN, IPCC_OBSERVED, mBlockHeaderLines, mFileHeaderLines, mFileType, mGdalDataset, mXDim, mYDim, NCAR_CSM_PCM, and VALDES.

Referenced by initialise().

const long OmgClimateFileReader::xDim  ) 
 

Read property of long mXDim.

Definition at line 88 of file omgclimatefilereader.cpp.

References mXDim.

Referenced by OmgRasterThreshold::accept(), and OmgClimateImporter::import().

const long OmgClimateFileReader::yDim  ) 
 

Read property of long mYDim.

Definition at line 96 of file omgclimatefilereader.cpp.

References mYDim.

Referenced by OmgRasterThreshold::accept(), and OmgClimateImporter::import().


Member Data Documentation

int OmgClimateFileReader::mActiveBlockNo [private]
 

Block in file that matrix extraction should start at.

Definition at line 254 of file omgclimatefilereader.h.

Referenced by activeBlock(), and setActiveBlock().

int OmgClimateFileReader::mBlockHeaderLines [private]
 

Number of header lines per month data block (applicable to files containing multiple months in a single file only.

Definition at line 271 of file omgclimatefilereader.h.

Referenced by blockHeaderLineCount(), getBlockMarkers(), and setFileType().

QVector<int> OmgClimateFileReader::mBlockMarkersVector [private]
 

This is a vector that stores the filepos for each datablock in the file

Definition at line 275 of file omgclimatefilereader.h.

Referenced by blockCount(), getBlockMarkers(), printBlockMarkers(), printFirstCellInEachBlock(), printLastCellInEachBlock(), and setActiveBlock().

int OmgClimateFileReader::mBlockStartPos [private]
 

The offset of the start of the header. This may not be after the header in instances where files contain more the one dataset.

Definition at line 273 of file omgclimatefilereader.h.

Referenced by blockStartPos(), and setActiveBlock().

char OmgClimateFileReader::mBuffer[mMaxLineLength] [private]
 

This is a buffer for holding read in lines

Definition at line 266 of file omgclimatefilereader.h.

Referenced by getBlockMarkers().

unsigned int OmgClimateFileReader::mCurrentColumn [private]
 

Current column in the matrix

Definition at line 258 of file omgclimatefilereader.h.

Referenced by currentCol(), getBlockMarkers(), getElement(), initialise(), and setActiveBlock().

unsigned int OmgClimateFileReader::mCurrentElementNo [private]
 

Position in the matrix expressed as (current row * cols) + current col

Definition at line 262 of file omgclimatefilereader.h.

Referenced by currentElementNo(), getBlockMarkers(), getElement(), initialise(), and setActiveBlock().

unsigned int OmgClimateFileReader::mCurrentRow [private]
 

Current row in matrix

Definition at line 260 of file omgclimatefilereader.h.

Referenced by currentRow(), getBlockMarkers(), getElement(), initialise(), and setActiveBlock().

bool OmgClimateFileReader::mEndOfMatrixFlag [private]
 

Whether the file pointer has reached the end of the matrix

Definition at line 252 of file omgclimatefilereader.h.

Referenced by getElement(), initialise(), isAtMatrixEnd(), and setActiveBlock().

int OmgClimateFileReader::mFileHeaderLines [private]
 

Number of header lines specifically at start of file.

Definition at line 256 of file omgclimatefilereader.h.

Referenced by getBlockMarkers(), headerLineCount(), and setFileType().

QString OmgClimateFileReader::mFileName [private]
 

The name of the file, including full path if neccessary.

Definition at line 250 of file omgclimatefilereader.h.

Referenced by filename(), getBlockMarkers(), and initialise().

FileType OmgClimateFileReader::mFileType [private]
 

Type of file we are reading.

Definition at line 248 of file omgclimatefilereader.h.

Referenced by getBlockMarkers(), getElement(), getFileType(), setFileType(), and ~OmgClimateFileReader().

GDALDataset* OmgClimateFileReader::mGdalDataset [private]
 

if the file type is a gdal dataset we will store the handle to the dataset here rather than in the text stream

Definition at line 268 of file omgclimatefilereader.h.

Referenced by getElement(), initialise(), setFileType(), and ~OmgClimateFileReader().

const unsigned int OmgClimateFileReader::mMaxLineLength = 100 [static, private]
 

This is a maximum length for lines that shall be skipped

Definition at line 242 of file omgclimatefilereader.h.

Referenced by getBlockMarkers().

std::ifstream OmgClimateFileReader::mTextStream [private]
 

The text stream that will be used to pull data from the file

Definition at line 264 of file omgclimatefilereader.h.

Referenced by getBlockMarkers(), getElement(), initialise(), setActiveBlock(), and ~OmgClimateFileReader().

unsigned int OmgClimateFileReader::mXDim [private]
 

This is the xDim (columns) of a matrix for one month (files may contain more than one matrix).

Definition at line 244 of file omgclimatefilereader.h.

Referenced by getBlockMarkers(), getElement(), setFileType(), and xDim().

unsigned int OmgClimateFileReader::mYDim [private]
 

Number of rows in matrix for one month / year

Definition at line 246 of file omgclimatefilereader.h.

Referenced by getBlockMarkers(), getElement(), setFileType(), and yDim().


The documentation for this class was generated from the following files:
Generated on Mon Apr 28 15:12:43 2008 for openModellerDesktop by  doxygen 1.4.1-20050210