SFA Project On-line Documentation: FileIO

The FileIO class is responsible for all the Disk File Input/Output for SFA. It reads in a meta-data in the form of a .set file and then reads the actual data files. It then initializes an instance of a DataSet and adds this DataSet to the DataSetList.

The FileIO is also used to save the current state of a DataSet to a meta-data file . This will write back a .set file and store information such as Dimension Labels and Dimension Mappings. 


//
//  FileIO.H  
//
//  This file defines the file IO class used to read in data
//  from files and plug it into DataSetList class .
//
//  Pradyut Panda  Feb 1998.
//

# ifndef SFA_FILEIO_H
# define SFA_FILEIO_H 1

# include 
# include 
# include 
# include 

# include "DataSetList.H"
# include "String.H"
# include "Defines.H"


class FileIO
{
  // place holders for the DataSet information

  String  set_label; 
  String  **file_names, *dim_labels ;
  String  mapping_names [SFA_NUM_MAP_FIELDS];
  
  String  *maps;
  int     *num_maps_dimen; 
  int     dimensions, length, time_steps ; 

public :

  // Constructor and Destructor
  FileIO();
  ~FileIO();

  // read meta data from a .set file
  void initialize( char *file_name );

  // create the dataSet and plug-in values
  void readData( char *file_name, DataSetList *d );

  // write out meta data to a .set file
  void writeData( char *file_name, DataSetList d  );

  // test routine
  void print( void );

};

# endif 


Constructors

void FileIO( void )

The FileIO constructor does some initializing for the FileIO class. It sets the mapping_names array. This array contains the names that the user can use to specify mappings for different dimensions in the .set file. The FileIO class has place holders to store data read from a .set file. These variables are initialized to NULL or a 0. 

Mutators

~FileIO( void )

The FileIO Destructor function frees up space that was reserved for the place holders for the meta-data. 

Reading and writing meta-data

void initialize( char *file_name )

The initialize function opens file_name. This file contains the meta-data for a DataSet. The function then allocates space for storage locations for the meta-data and reads in the meta-data and stores it in the place holders which are part of the FileIO class.

void readData( char *file_name, DataSetList *d )

The readData function calls the initialize function to read in the meta-data from file_name. It then tries to open and read the actual data files. If successful it creates a new instance of the DataSet class and stores the data in it. It then adds the new DataSet to the DataSetList d .

void writeData( char *file_name, DataSetList d )

The writeData function saves the current state of the DataSet pointed to by the current pointer of the DataSetList d. It writes a .set file call file_name. This is used if the user has changed Dimension Mappings or Dimension Labels and wants to save the changes. 
Pradyut Panda

Last modified: Mon Mar 30 10:23:40 EST 1998