Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
variant_iterator.h
Go to the documentation of this file.
1 #ifndef gamgee__variant_iterator__guard
2 #define gamgee__variant_iterator__guard
3 
4 #include "variant.h"
5 
6 #include "htslib/vcf.h"
7 
8 #include <memory>
9 
10 namespace gamgee {
11 
16  public:
17 
21  VariantIterator() = default;
22 
29  VariantIterator(const std::shared_ptr<htsFile>& variant_file_ptr, const std::shared_ptr<bcf_hdr_t>& variant_header_ptr);
30 
34  VariantIterator(VariantIterator&&) = default;
35 
40 
44  VariantIterator(const VariantIterator&) = delete;
45 
49  VariantIterator& operator= (const VariantIterator&) = delete;
50 
59  bool operator!=(const VariantIterator& rhs) const;
60 
66  Variant& operator*();
67 
75 
81  bool empty() const;
82 
83  protected:
84  std::shared_ptr<htsFile> m_variant_file_ptr;
85  std::shared_ptr<bcf_hdr_t> m_variant_header_ptr;
86  std::shared_ptr<bcf1_t> m_variant_record_ptr;
88 
89  virtual void fetch_next_record();
90 };
91 
92 } // end namespace gamgee
93 
94 #endif // gamgee__variant_iterator__guard
Variant & operator++()
pre-fetches the next record and tests for end of file
Definition: variant_iterator.cpp:23
virtual void fetch_next_record()
fetches next Variant record into existing htslib memory without making a copy
Definition: variant_iterator.cpp:40
std::shared_ptr< bcf_hdr_t > m_variant_header_ptr
pointer to the variant header
Definition: variant_iterator.h:85
bool operator!=(const VariantIterator &rhs) const
inequality operator (needed by for-each loop)
Definition: variant_iterator.cpp:28
VariantIterator & operator=(VariantIterator &&)=default
a VariantIterator move assignment operator guarantees all objects will have the same state...
VariantIterator()=default
creates an empty iterator (used for the end() method)
Variant & operator*()
dereference operator (needed by for-each loop)
Definition: variant_iterator.cpp:19
Utility class to enable for-each style iteration in the VariantReader class.
Definition: variant_iterator.h:15
Variant m_variant_record
temporary record to hold between fetch (operator++) and serve (operator*)
Definition: variant_iterator.h:87
Definition: exceptions.h:9
bool empty() const
returns whether the iterator has no additional records
Definition: variant_iterator.cpp:32
std::shared_ptr< bcf1_t > m_variant_record_ptr
pointer to the internal structure of the variant record. Useful to only allocate it once...
Definition: variant_iterator.h:86
Utility class to manipulate a Variant record.
Definition: variant.h:29
std::shared_ptr< htsFile > m_variant_file_ptr
pointer to the vcf/bcf file
Definition: variant_iterator.h:84