]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/api/BamIndex.h
Cleaned up intra-API includes & moved version numbers to 2.0.0
[bamtools.git] / src / api / BamIndex.h
index 00a8f0174458f542268944d30aa39997400d0338..5e40d87eb517d4fbc8797e8f5d874eb520602f56 100644 (file)
@@ -1,9 +1,8 @@
 // ***************************************************************************
 // BamIndex.h (c) 2009 Derek Barnett
 // Marth Lab, Department of Biology, Boston College
 // ***************************************************************************
 // BamIndex.h (c) 2009 Derek Barnett
 // Marth Lab, Department of Biology, Boston College
-// All rights reserved.
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
-// Last modified: 5 April 2011 (DB)
+// Last modified: 10 October 2011 (DB)
 // ---------------------------------------------------------------------------
 // Provides basic BAM index interface
 // ***************************************************************************
 // ---------------------------------------------------------------------------
 // Provides basic BAM index interface
 // ***************************************************************************
@@ -11,8 +10,8 @@
 #ifndef BAM_INDEX_H
 #define BAM_INDEX_H
 
 #ifndef BAM_INDEX_H
 #define BAM_INDEX_H
 
-#include <api/api_global.h>
-#include <api/BamAux.h>
+#include "api/api_global.h"
+#include "api/BamAux.h"
 #include <string>
 
 namespace BamTools {
 #include <string>
 
 namespace BamTools {
@@ -30,8 +29,6 @@ namespace Internal {
 
     It is exposed to the public API to allow advanced users to implement
     their own custom indexing schemes.
 
     It is exposed to the public API to allow advanced users to implement
     their own custom indexing schemes.
-
-    More documentation on methods & enums coming soon.
 */
 
 class API_EXPORT BamIndex {
 */
 
 class API_EXPORT BamIndex {
@@ -57,22 +54,40 @@ class API_EXPORT BamIndex {
     // index interface
     public:
         // builds index from associated BAM file & writes out to index file
     // index interface
     public:
         // builds index from associated BAM file & writes out to index file
-        virtual bool Create(void) =0; // creates index file from BAM file
+        virtual bool Create(void) =0;
+
+        // returns a human-readable description of the last error encountered
+        std::string GetErrorString(void) { return m_errorString; }
+
         // returns whether reference has alignments or no
         virtual bool HasAlignments(const int& referenceID) const =0;
         // returns whether reference has alignments or no
         virtual bool HasAlignments(const int& referenceID) const =0;
+
         // attempts to use index data to jump to @region, returns success/fail
         // a "successful" jump indicates no error, but not whether this region has data
         //   * thus, the method sets a flag to indicate whether there are alignments
         //     available after the jump position
         virtual bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion) =0;
         // attempts to use index data to jump to @region, returns success/fail
         // a "successful" jump indicates no error, but not whether this region has data
         //   * thus, the method sets a flag to indicate whether there are alignments
         //     available after the jump position
         virtual bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion) =0;
+
         // loads existing data from file into memory
         virtual bool Load(const std::string& filename) =0;
         // loads existing data from file into memory
         virtual bool Load(const std::string& filename) =0;
+
         // change the index caching behavior
         virtual void SetCacheMode(const BamIndex::IndexCacheMode& mode) =0;
 
         // change the index caching behavior
         virtual void SetCacheMode(const BamIndex::IndexCacheMode& mode) =0;
 
+    //! \cond
+
+    // internal methods
+    protected:
+        void SetErrorString(const std::string& where, const std::string& what) const {
+            m_errorString = where + ": " + what;
+        }
+
     // data members
     protected:
     // data members
     protected:
-        Internal::BamReaderPrivate* m_reader; // copy, not ownedprivate:
+        Internal::BamReaderPrivate* m_reader; // copy, not owned
+        mutable std::string m_errorString;
+
+    //! \endcond
 };
 
 } // namespace BamTools
 };
 
 } // namespace BamTools