00001 ///////////////////////////////////////////////////////////////////////////// 00002 // File: gnSourceHeader.h 00003 // Purpose: Source Header class 00004 // Description: Provides an interface for Headers on disk. 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 _gnSourceHeader_h_ 00013 #define _gnSourceHeader_h_ 00014 00015 #include "gn/gnDefs.h" 00016 00017 #include <string> 00018 #include "gn/gnBaseHeader.h" 00019 #include "gn/gnBaseSource.h" 00020 00021 #include <utility> 00022 00023 /** 00024 * gnSourceHeader is used to store a sequence header which resides in another source. 00025 * gnSourceHeaders are created by gnSEQSource and other sources and placed into a spec. 00026 */ 00027 class GNDLLEXPORT gnSourceHeader : public gnBaseHeader 00028 { 00029 public: 00030 /** 00031 * Empty constructor. 00032 */ 00033 gnSourceHeader(); 00034 /** 00035 * Constructor, records the header's name and byte offset in the source. 00036 * @param source The source which contains the header. 00037 * @param name The name of the header. 00038 * @param begin The offset into the source where the header starts. 00039 * @param length The length of the header. 00040 */ 00041 gnSourceHeader( gnBaseSource* source, const string& name, const uint32 begin, const uint32 length ); 00042 /** 00043 * Copy constructor. 00044 * @param s The gnSourceHeader to copy. 00045 */ 00046 gnSourceHeader( const gnSourceHeader& s ); 00047 /** 00048 * Destructor, frees memory. 00049 */ 00050 ~gnSourceHeader(); 00051 00052 gnSourceHeader* Clone() const; 00053 00054 string GetHeader() const; 00055 string GetHeaderName() const; 00056 /// Not implemented, use gnStringHeader. 00057 // void SetHeader(const string& header){}; 00058 /// Not implemented, use gnStringHeader. 00059 // void SetHeaderName(const string& name){}; 00060 00061 uint32 GetLength() const; 00062 /** 00063 * Get the header's start position within the source. 00064 * @return The byte offset of the header's start position. 00065 */ 00066 uint32 GetHeaderStart() const; 00067 /** 00068 * Get the header's start position and length within the source. 00069 * @return The header start position and length as a pair. 00070 */ 00071 pair<uint32, uint32> GetHeaderLoc() const; 00072 00073 /** 00074 * Set the header's start position within the source. 00075 * @param start The header start position. 00076 */ 00077 void SetHeaderStart(const uint32 start); 00078 /** 00079 * Get the header's length within the source. 00080 * @param length The header length. 00081 */ 00082 void SetHeaderLength(const uint32 length); 00083 /** 00084 * Set the header's start position and length within the source. 00085 * @param startLen The header start position and length as a pair. 00086 */ 00087 void SetHeaderLoc(const pair<uint32, uint32> startLen); 00088 00089 private: 00090 string m_name; 00091 uint32 m_start, m_length; 00092 gnBaseSource *m_source; 00093 }; //class gnSourceHeader 00094 00095 inline 00096 gnSourceHeader* gnSourceHeader::Clone() const{ 00097 return new gnSourceHeader(*this); 00098 } 00099 inline 00100 string gnSourceHeader::GetHeaderName() const{ 00101 return m_name; 00102 } 00103 inline 00104 uint32 gnSourceHeader::GetHeaderStart() const{ 00105 return m_start; 00106 } 00107 inline 00108 uint32 gnSourceHeader::GetLength() const{ 00109 return m_length; 00110 } 00111 inline 00112 pair<uint32, uint32> gnSourceHeader::GetHeaderLoc() const{ 00113 pair<uint32, uint32> p; 00114 p.first = m_start; 00115 p.second = m_length; 00116 return p; 00117 } 00118 inline 00119 void gnSourceHeader::SetHeaderStart(const uint32 start){ 00120 m_start = start; 00121 } 00122 inline 00123 void gnSourceHeader::SetHeaderLength(const uint32 length){ 00124 m_length = length; 00125 } 00126 inline 00127 void gnSourceHeader::SetHeaderLoc(const pair<uint32, uint32> startLen){ 00128 m_start = startLen.first; 00129 m_length = startLen.second; 00130 } 00131 00132 00133 #endif 00134 // _gnSourceHeader_h_