FileType.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 __FILETYPE_H__
00019 #define __FILETYPE_H__
00020 
00021 class FileType
00022 {
00023 public:
00024     FileType();
00025     virtual ~FileType();
00026 
00027     virtual bool operator == (void * rhs) = 0;
00028 
00029     virtual bool operator != (void * rhs) = 0;
00030 
00031     // Close the file.
00032     virtual int close() = 0;
00033 
00034     // Reset to the beginning of the file.
00035     virtual void rewind() = 0;
00036 
00037     // Check to see if we have reached the EOF.
00038     virtual int eof() = 0;
00039 
00040     // Check to see if the file is open.
00041     virtual bool isOpen() = 0;
00042 
00043     // Write to the file.
00044     virtual unsigned int write(const void * buffer, unsigned int size) = 0;
00045 
00046     // Read into a buffer from the file.
00047     virtual int read(void * buffer, unsigned int size) = 0;
00048 
00049     // Get current position in the file.
00050     // -1 return value indicates an error.
00051     virtual long int tell() = 0;
00052 
00053     // Seek to the specified offset from the origin.
00054     // origin can be any of the following:
00055     // Note: not all are valid for all filetypes.
00056     //   SEEK_SET - Beginning of file
00057     //   SEEK_CUR - Current position of the file pointer
00058     //   SEEK_END - End of file
00059     // Returns true on successful seek and false on a failed seek.
00060     virtual bool seek(long int offset, int origin) = 0;
00061 
00062     // Set by the InputFile to inform this class if buffering
00063     // is used.  Maybe used by child clases (bgzf) to disable 
00064     // tell.  NOTE: this class does no buffering, the
00065     // buffering is handled by the calling class.
00066     void setBuffered(bool buffered);
00067 
00068 protected:
00069     // Set by the InputFile to inform this class if buffering
00070     // is used.  Maybe used by child clases (bgzf) to disable 
00071     // tell.
00072     bool myUsingBuffer;
00073 };
00074 
00075 #endif
00076 
Generated on Tue Mar 22 22:50:17 2011 for StatGen Software by  doxygen 1.6.3