GlfFile.h

00001 /*
00002  *  Copyright (C) 2010  Regents of the University of Michigan
00003  *
00004  *   This program is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #ifndef __GLF_FILE_H__
00019 #define __GLF_FILE_H__
00020 
00021 #include "InputFile.h"
00022 #include "GlfHeader.h"
00023 #include "GlfRefSection.h"
00024 #include "GlfRecord.h"
00025 #include "GlfStatus.h"
00026 
00027 class GlfFile
00028 {
00029 public:
00030     enum OpenType {READ, WRITE};
00031 
00033     GlfFile();
00034 
00039     GlfFile(const char* filename, OpenType mode = READ);
00040 
00041     virtual ~GlfFile();
00042    
00046     bool openForRead(const char * filename);
00047 
00052     bool openForRead(const char * filename, GlfHeader& header);
00053 
00056     bool openForWrite(const char * filename);
00057 
00059     void close();
00060 
00064     bool isEOF();
00065    
00069     bool readHeader(GlfHeader& header);
00070    
00073     bool writeHeader(GlfHeader& header);
00074 
00079     bool getNextRefSection(GlfRefSection& refSection);
00080    
00083     bool writeRefSection(const GlfRefSection& refSection);
00084 
00089     bool getNextRecord(GlfRecord& record);
00090    
00093     bool writeRecord(const GlfRecord& record);
00094    
00096     uint32_t getCurrentRecordCount();
00097 
00100     inline GlfStatus::Status getFailure()
00101     {
00102         return(getStatus());
00103     }
00104 
00106     inline GlfStatus::Status getStatus()
00107     {
00108         return(myStatus.getStatus());
00109     }
00110 
00112     inline const char* getStatusMessage()
00113     {
00114         return(myStatus.getStatusMessage());
00115     }
00116 
00117 protected:
00118     void resetFile();
00119 
00120     IFILE  myFilePtr;
00121 
00123     bool myIsOpenForRead;
00125     bool myIsOpenForWrite;
00128     bool myHasHeader;
00131     bool myHasRefSection;
00132     
00133 
00135     uint32_t myRecordCount;
00136 
00138     GlfStatus myStatus;
00139 };
00140 
00141 
00142 class GlfFileReader : public GlfFile
00143 {
00144 public:
00145 
00147     GlfFileReader();
00148 
00150     GlfFileReader(const char* filename);
00151 
00152     virtual ~GlfFileReader();
00153 };
00154 
00155 
00156 class GlfFileWriter : public GlfFile
00157 {
00158 public:
00160     GlfFileWriter();
00161 
00163     GlfFileWriter(const char* filename);
00164 
00165     virtual ~GlfFileWriter();
00166 };
00167 
00168 #endif
Generated on Tue Nov 9 16:11:49 2010 for StatGen Software by  doxygen 1.6.3