libStatGen Software  1
GlfRefSection.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_REFSECTION_H__
00019 #define __GLF_REFSECTION_H__
00020 
00021 #include <stdint.h>
00022 
00023 #include "InputFile.h" 
00024 #include "CharBuffer.h"
00025 
00026 ///This class allows a user to easily get/set the fields in a
00027 /// GLF section/chromosome header.
00028 /// The GlfRefSection contains:
00029 /// - Reference Sequence Name
00030 /// - Reference Sequence Length 
00031 class GlfRefSection
00032 {
00033 public:
00034     GlfRefSection();
00035     ~GlfRefSection();
00036 
00037     /// Copy Constructor
00038     /// \param refSection reference section to copy into this one.
00039     GlfRefSection(const GlfRefSection& refSection);
00040 
00041     /// Overload operator= to copy the passed in refSection into this one.
00042     /// \param refSection reference section to copy into this one.
00043     GlfRefSection & operator = (const GlfRefSection& refSection);
00044 
00045     /// Copy the passed in refSection into this refSection.
00046     /// \param refSection reference section to copy into this one.
00047     bool copy(const GlfRefSection& refSection);
00048 
00049     /// Clear this reference section back to the default setting.
00050     void resetRefSection();
00051    
00052     /// Read the refSection from the specified file (file MUST be in
00053     /// the correct position for reading a refSection).
00054     /// \param filePtr file to read from that is in the correct position.
00055     /// \return true if the reference section was successfully read from the 
00056     /// file, false if not.
00057     bool read(IFILE filePtr);
00058 
00059     /// Write the refSection to the specified file.
00060     /// \param filePtr file to write to that is in the correct position.
00061     /// \return true if the reference section was successfully written to the 
00062     /// file, false if not.
00063     bool write(IFILE filePtr) const;
00064 
00065     /////////////
00066     // Accessors.
00067 
00068     /// Get the reference name.
00069     /// \param name string to populate with the reference name.
00070     /// \return true if the name was successfully returned, false if not.
00071     bool getName(std::string& name) const;
00072 
00073     /// Get the length of the reference sequence.
00074     /// \return reference sequence length for this reference section.
00075     uint32_t getRefLen() const;
00076 
00077     /// Set the reference name.
00078     /// \param name reference name to set this section to.
00079     /// \return true if the name was successfully set, false if not.
00080     bool setName(const std::string& name);
00081     /// Set the length of the reference sequence.
00082     /// \param refLen reference sequence length to set this section to.
00083     /// \return true if the length was successfully set, false if not.
00084     bool setRefLen(uint32_t refLen);
00085 
00086     /// Print the reference section in a readable format.
00087     void print() const;
00088 
00089 private:
00090     CharBuffer myRefName;
00091     uint32_t myRefLen;
00092 };
00093 
00094 #endif
00095 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends