gnFileSource.h Source File

Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# gnFileSource.h

Go to the documentation of this file.

    00001 /////////////////////////////////////////////////////////////////////////////
    00002 // File:            gnFileSource.h
    00003 // Purpose:         Implements gnBaseSource for .File files
    00004 // Description:
    00005 // Changes:
    00006 // Version:         libGenome 0.5.1
    00007 // Author:          Aaron Darling
    00008 // Modified by:
    00009 // Copyright:       (c) Aaron Darling
    00010 // Licenses:        See COPYING file for details
    00011 /////////////////////////////////////////////////////////////////////////////
    00012 #ifndef _gnFileSource_h_
    00013 #define _gnFileSource_h_
    00014
    00015 #include "gn/gnDefs.h"
    00016
    00017 #include <string>
    00018 #include <fstream>
    00019 #include "gn/gnBaseSource.h"
    00020 #include "gn/gnFileContig.h"
    00021 #include "gn/gnException.h"
    00022
    00023 /**
    00024  * gnFileSource is a standard interface to all file based sources of genetic information.
    00025  * All file source classes are derived from this class.
    00026  */
    00027 class GNDLLEXPORT gnFileSource : public gnBaseSource
    00028 {
    00029 public:
    00030         gnFileSource(){}
    00031         gnFileSource(const gnFileSource& gnfs);
    00032         virtual ~gnFileSource(){}
    00033         virtual gnFileSource* Clone() const = 0;
    00034         // Open, Close
    00035         virtual void Open( string openString );
    00036         virtual void Open();
    00037         virtual void Close();
    00038         virtual string GetOpenString() const ;
    00039           // Filter
    00040         virtual const gnFilter* GetFilter() const ;
    00041         virtual void SetFilter( gnFilter* filter );
    00042
    00043         virtual boolean Read( const uint64 pos, char* buf, uint32& bufLen );
    00044         /**
    00045          * Returns a pointer to the file contig corresponding to contigI or
    00046          * null if none exists.
    00047          */
    00048         virtual gnFileContig* GetFileContig( const uint32 contigI ) const = 0;
    00049 protected:
    00050         void DetermineNewlineType();
    00051
    00052         string m_openString;
    00053         ifstream m_ifstream;
    00054         const gnFilter* m_pFilter;
    00055         gnNewlineType m_newlineType;
    00056         uint32 m_newlineSize;
    00057 private:
    00058         virtual boolean ParseStream( istream& fin ) = 0;
    00059 };// class gnFileSource
    00060
    00061 inline
    00062 string gnFileSource::GetOpenString( ) const
    00063 {
    00064         return m_openString;
    00065 }
    00066 // Filter
    00067 inline
    00068 const gnFilter* gnFileSource::GetFilter() const
    00069 {
    00070         return m_pFilter;
    00071 }
    00072
    00073 inline
    00074 void gnFileSource::SetFilter( gnFilter* filter )
    00075 {
    00076         if(filter == NULL){
    00077                 Throw_gnEx(NullPointer());
    00078         }
    00079         m_pFilter = filter;
    00080 }
    00081
    00082 #endif
    00083         // _gnFileSource_h_