Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
gamgee::VariantIterator Class Reference

Utility class to enable for-each style iteration in the VariantReader class. More...

#include <variant_iterator.h>

Inheritance diagram for gamgee::VariantIterator:
gamgee::IndexedVariantIterator

Public Member Functions

 VariantIterator ()=default
 creates an empty iterator (used for the end() method) More...
 
 VariantIterator (const std::shared_ptr< htsFile > &variant_file_ptr, const std::shared_ptr< bcf_hdr_t > &variant_header_ptr)
 initializes a new iterator based on an input stream (e.g. a vcf/bcf file, stdin, ...) More...
 
 VariantIterator (VariantIterator &&)=default
 a VariantIterator move constructor guarantees all objects will have the same state. More...
 
VariantIteratoroperator= (VariantIterator &&)=default
 a VariantIterator move assignment operator guarantees all objects will have the same state. More...
 
 VariantIterator (const VariantIterator &)=delete
 a VariantIterator cannot be copy-constructed. More...
 
VariantIteratoroperator= (const VariantIterator &)=delete
 a VariantIterator cannot be copied. More...
 
bool operator!= (const VariantIterator &rhs) const
 inequality operator (needed by for-each loop) More...
 
Variantoperator* ()
 dereference operator (needed by for-each loop) More...
 
Variantoperator++ ()
 pre-fetches the next record and tests for end of file More...
 
bool empty () const
 returns whether the iterator has no additional records More...
 

Protected Member Functions

virtual void fetch_next_record ()
 fetches next Variant record into existing htslib memory without making a copy More...
 

Protected Attributes

std::shared_ptr< htsFilem_variant_file_ptr
 pointer to the vcf/bcf file More...
 
std::shared_ptr< bcf_hdr_tm_variant_header_ptr
 pointer to the variant header More...
 
std::shared_ptr< bcf1_tm_variant_record_ptr
 pointer to the internal structure of the variant record. Useful to only allocate it once. More...
 
Variant m_variant_record
 temporary record to hold between fetch (operator++) and serve (operator*) More...
 

Detailed Description

Utility class to enable for-each style iteration in the VariantReader class.

Constructor & Destructor Documentation

gamgee::VariantIterator::VariantIterator ( )
default

creates an empty iterator (used for the end() method)

gamgee::VariantIterator::VariantIterator ( const std::shared_ptr< htsFile > &  variant_file_ptr,
const std::shared_ptr< bcf_hdr_t > &  variant_header_ptr 
)

initializes a new iterator based on an input stream (e.g. a vcf/bcf file, stdin, ...)

Parameters
variant_file_ptrshared pointer to a vcf/bcf file opened via the bcf_open() macro from htslib
variant_header_ptrshared pointer to a vcf/bcf file header created with the bcf_hdr_read() macro from htslib
gamgee::VariantIterator::VariantIterator ( VariantIterator &&  )
default

a VariantIterator move constructor guarantees all objects will have the same state.

gamgee::VariantIterator::VariantIterator ( const VariantIterator )
delete

a VariantIterator cannot be copy-constructed.

Member Function Documentation

bool gamgee::VariantIterator::empty ( ) const

returns whether the iterator has no additional records

Returns
true if the the iterator has no additional records
void gamgee::VariantIterator::fetch_next_record ( )
protectedvirtual

fetches next Variant record into existing htslib memory without making a copy

pre-fetches the next variant record

Warning
we're reusing the existing htslib memory, so users should be aware that all objects from the previous iteration are now stale unless a deep copy has been performed

Reimplemented in gamgee::IndexedVariantIterator.

bool gamgee::VariantIterator::operator!= ( const VariantIterator rhs) const

inequality operator (needed by for-each loop)

Parameters
rhsthe other VariantIterator to compare to
Returns
whether or not the two iterators are the same (e.g. have the same input stream on the same status)
Variant & gamgee::VariantIterator::operator* ( )

dereference operator (needed by for-each loop)

Returns
a persistent Variant object independent from the iterator (a copy of the iterator's object)
Variant & gamgee::VariantIterator::operator++ ( )

pre-fetches the next record and tests for end of file

Returns
a reference to the object (it can be const& because this return value should only be used by the for-each loop to check for the eof)
VariantIterator& gamgee::VariantIterator::operator= ( VariantIterator &&  )
default

a VariantIterator move assignment operator guarantees all objects will have the same state.

VariantIterator& gamgee::VariantIterator::operator= ( const VariantIterator )
delete

a VariantIterator cannot be copied.

Member Data Documentation

std::shared_ptr<htsFile> gamgee::VariantIterator::m_variant_file_ptr
protected

pointer to the vcf/bcf file

std::shared_ptr<bcf_hdr_t> gamgee::VariantIterator::m_variant_header_ptr
protected

pointer to the variant header

Variant gamgee::VariantIterator::m_variant_record
protected

temporary record to hold between fetch (operator++) and serve (operator*)

std::shared_ptr<bcf1_t> gamgee::VariantIterator::m_variant_record_ptr
protected

pointer to the internal structure of the variant record. Useful to only allocate it once.


The documentation for this class was generated from the following files: