DataFile Class Reference
[Framework Module]

#include <datafile.h>

Inheritance diagram for DataFile:

AudioFile FontFile ImageFile OggAudioFile FreeTypeFontFile TgaImageFile

List of all members.


Detailed Description

Provides read / write access to any data file, text or binary.

This class is the base for all data files used in framework. All data files has to use File object for reading and writing the data. This File object is creted and file is opend/close here.

Each descendant can define the type of data file (text / binary) in constructor and should define all virtual methods, especially LoadData and DeleteData.

Public Types

enum  LoadState { LS_UNLOADED, LS_BLOCK_LOADED, LS_LOADED }

Public Member Functions

 DataFile ()
virtual ~DataFile ()
virtual bool Open (bool write=false)
virtual void Close ()
virtual ulong_t LoadData ()
virtual bool SaveData ()
void SetFileName (const string &file_name)
const string & GetFileName ()
ulong_t GetDataSize ()
LoadState GetState ()
bool TestState (LoadState state)
bool IsOpened ()

Protected Member Functions

virtual void DeleteData ()=0

Protected Attributes

Filefile
 File object. This object is automatically creted in Open method and destroyed in Close method.
string file_name
 File name with path (relative or absolute).
LoadState state
 Loading state of the file.
bool opened
 Whether file is opened or not.
bool binary
 Whether file will be opened in binary mode. Set this property before opening the file.
ulong_t data_size
 Whole size of loaded data. Data size should by calculated in LoadData method.


Member Enumeration Documentation

enum DataFile::LoadState

Loading state of the file.

Enumerator:
LS_UNLOADED  The file is not loaded yet.
LS_BLOCK_LOADED  Block of data has been loaded from the file.
LS_LOADED  Whole file has been loaded.


Constructor & Destructor Documentation

DataFile::DataFile (  ) 

Constructor.

DataFile::~DataFile (  )  [virtual]

Destructor.


Member Function Documentation

bool DataFile::Open ( bool  write = false  )  [virtual]

Opens data file. Just creates File object for access to file in filesystem.

Parameters:
write Whether file will be opened for writing.
Returns:
True if successful.

Reimplemented in FreeTypeFontFile, and OggAudioFile.

void DataFile::Close (  )  [virtual]

Close data file. Deletes data and File object. Data file has to be opened before.

Reimplemented in FreeTypeFontFile, and OggAudioFile.

ulong_t DataFile::LoadData (  )  [virtual]

Loads data from opened file. Data has to be unloaded before. This function should be redefined in derived classes.

Returns:
Size of loaded data.

Reimplemented in FreeTypeFontFile, OggAudioFile, TgaImageFile, and ImageFile.

bool DataFile::SaveData (  )  [virtual]

Saves data into the file. Data has to be loaded before. This function can be redefined in derived classes.

Returns:
True if successful.

Reimplemented in TgaImageFile.

void DataFile::SetFileName ( const string &  file_name  )  [inline]

Sets file name with path (relative or absolute).

Parameters:
file_name File name with path.

const string & DataFile::GetFileName (  )  [inline]

ulong_t DataFile::GetDataSize (  )  [inline]

Returns data size.

Returns:
Data size.

DataFile::LoadState DataFile::GetState (  )  [inline]

Returns load state of the file.

Returns:
Load state.

bool DataFile::TestState ( LoadState  state  )  [inline]

Tests given state.

Parameters:
state Loading state to be tested.
Returns:
True if given state is same as state of the file.

bool DataFile::IsOpened (  )  [inline]

Returns opening state.

Returns:
Whether file is openes.

virtual void DataFile::DeleteData (  )  [protected, pure virtual]

Implemented in AudioFile, FontFile, and ImageFile.


Member Data Documentation

File* DataFile::file [protected]

File object. This object is automatically creted in Open method and destroyed in Close method.

string DataFile::file_name [protected]

File name with path (relative or absolute).

LoadState DataFile::state [protected]

Loading state of the file.

bool DataFile::opened [protected]

Whether file is opened or not.

bool DataFile::binary [protected]

Whether file will be opened in binary mode. Set this property before opening the file.

ulong_t DataFile::data_size [protected]

Whole size of loaded data. Data size should by calculated in LoadData method.


The documentation for this class was generated from the following files:
Generated on Sat Oct 20 14:47:31 2007 for Dark Oberon by  doxygen 1.5.3