Waterflow
Visualize water in terrain
FileHandler Class Reference

Used to store float arrays, and/or load them from files. More...

#include <fileHandler.h>

List of all members.

Public Member Functions

 FileHandler (int dWidth, int dHeight)
 Constructor, takes file path as parameter.
float ** GetArray ()
 Getter for the stored float array.
int GetArrayLength ()
 Getter for the stored float array length.
int GetDataHeight ()
 Getter for the data height.
int GetDataWidth ()
 Getter for the data width.
int LoadData (std::string path)
 Loads data from a file specified by fPath into the object.
void SaveData (std::string path)
 Stores data, both as variables in the object and as a file.

Private Attributes

int arrayLength
 Length of the float array.
float * fArray
 Pointer to the float array.
int height
 Height (side information).
int width
 Width (side information).

Detailed Description

Used to store float arrays, and/or load them from files.

Use the fileHandler class to either store a generic float array, with some side information, or to load side information and a float array from the specified path. When attempting to load a file that does not exist, LoadData() returns -1, otherwise 0.

Definition at line 18 of file fileHandler.h.


Constructor & Destructor Documentation

FileHandler::FileHandler ( int  dWidth,
int  dHeight 
)

Constructor, takes file path as parameter.

path must either point to a file saved with this class, or towards a location where data should be saved.

Parameters:
dWidthWidth of the data to save, these are also set automatically when loading)
dHeightHeight of the data to save, these are also set automatically when loading)
See also:
SaveData()
LoadData()

Definition at line 9 of file fileHandler.cpp.


Member Function Documentation

float ** FileHandler::GetArray ( )

Getter for the stored float array.

Returns:
pointer to the float array.

Definition at line 94 of file fileHandler.cpp.

Getter for the stored float array length.

Returns:
length of the float array.

Definition at line 99 of file fileHandler.cpp.

Getter for the data height.

Returns:
height (side information).

Definition at line 108 of file fileHandler.cpp.

Getter for the data width.

Returns:
width (side information).

Definition at line 104 of file fileHandler.cpp.

int FileHandler::LoadData ( std::string  path)

Loads data from a file specified by fPath into the object.

Note that this method simply interprets a file as if it were saved with SaveData(). If the file specified by fPath is of another origin, the data loaded could be flagged as being correctly loaded, but in reality make little sense.

Returns:
0 if data was correctly loaded, -1 if the file could not be read.
See also:
SaveData()

Definition at line 44 of file fileHandler.cpp.

void FileHandler::SaveData ( std::string  path)

Stores data, both as variables in the object and as a file.

specified by fPath. Note that the file indicated by fPath will be created if it does not exist, and it will be overwritten if it does exist.

Parameters:
pathPath to the file to save, should be specified in the XML file

Definition at line 19 of file fileHandler.cpp.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations