/*  This header file reads in numbers from a data file, and puts it into an array
    which will be used later in TestData.C.
    
    The format which this code is designed to read is one column of numbers, the first
    number being an integer representing the number of data points in the file,  then
    followed by the actual data points.
    
*/
    
#include <fstream.h>

class ReadDataFile {

public:

     ReadDataFile(char* file):onefile(file) {
	
	onefile>>nset;				// Inputs the number that are in
						// the file.
 	dat=new float[nset];
               
          for (long i=0;i < nset;i++) {onefile>>dat[i];}  // Reads in the data to an array.
                       
     }
     
     ReadDataFile(char* file1,char* file2):firstfile(file1),secondfile(file2) {

	nset=0;				// Prompts the correct choice in 
					// the destructor
        	firstfile>>nset1;			
         	dat1=new float[nset1];     
                 
         	for (int i=0;i < nset1;i++) {firstfile>>dat1[i];}
 
     
	secondfile>>nset2;
         	dat2=new float[nset2];
         	                          
         	for (int i=0;i < nset2;i++) {secondfile>>dat2[i];}       
     }
     
     ~ReadDataFile();			
     
     float* Data();
     float* Data1();
     float* Data2();
     long DataNum();
     long Data1Num();
     long Data2Num();
     
private:

     float* dat;
     float* dat1;
     float* dat2;
     long nset;
     long nset1;
     long nset2;
     ifstream onefile;
     ifstream firstfile;
     ifstream secondfile;
     
}; 

ReadDataFile::~ReadDataFile() {		// Returns memory used by arrays back
					// too the computer, and closes the
     if(nset) {				// opened files.
     
          delete [] dat;
          onefile.close();
     }
     
     else {
          
           delete [] dat1;
           delete [] dat2;
           
           firstfile.close();
           secondfile.close();
     }
}                    

float* ReadDataFile::Data() {return dat;}
              
float* ReadDataFile::Data1() {return dat1;}
     
float* ReadDataFile::Data2() {return dat2;}
     
long ReadDataFile::DataNum() {return nset;}

long ReadDataFile::Data1Num() {return nset1;}

long ReadDataFile::Data2Num() {return nset2;}

             
         