Gamgee
You miserable little maggot. I'll stove your head in!
|
A class template to hold the values of a specific Variant's shared field. More...
#include <shared_field.h>
Public Member Functions | |
SharedField () | |
default constructor of an empty SharedField More... | |
SharedField (const std::shared_ptr< bcf1_t > &body, const bcf_info_t *const info_ptr) | |
creates a new SharedField pointing to the shared byte array inside the variant object More... | |
SharedField (const SharedField &other)=delete | |
copying of the SharedField object is not allowed. Use move constructor instead. More... | |
SharedField & | operator= (const SharedField &other)=delete |
copying of the SharedField object is not allowed. Use move constructor instead. More... | |
SharedField (SharedField &&other)=default | |
safely moves the data from one SharedField to a new one without making any copies More... | |
SharedField & | operator= (SharedField &&other)=default |
safely moves the data from one SharedField to the other without making any copies More... | |
bool | operator== (const SharedField &other) const |
compares two SharedField objects in the following order: memory address, size and values. More... | |
bool | operator!= (const SharedField &other) const |
compares two SharedField objects in the following order: memory address, size and values. More... | |
TYPE | operator[] (const uint32_t index) const |
random access to a given value for reading or writing More... | |
SharedFieldIterator< TYPE > | begin () const |
create a new iterator pointing to the begining of the values of this field More... | |
SharedFieldIterator< TYPE > | end () const |
create a new iterator pointing to the end of the values of this field More... | |
uint32_t | size () const |
the number of values in this SharedField (values per sample) More... | |
bool | empty () const |
checks if the object is empty. More... | |
bool | missing () const |
simple overload of empty to work with gamgee's missing API More... | |
TYPE | front () const |
convenience function to access the first element More... | |
TYPE | back () const |
convenience function to access the last element More... | |
template<> | |
uint32_t | size () const |
template<> | |
std::string | operator[] (const uint32_t index) const |
A class template to hold the values of a specific Variant's shared field.
The role of this class is to perform the pointer manipulations behind the scenes that permit the user to navigate the values of a field without making any copies and benefiting from data locality (all the data is stored contiguously in memory).
For example, the allele number shared field (AN) will hold one integer value. A ranksum test field for example could hold a vector of floats. The SharedField object will hold all these values for a shared field in a random access (and random access iterator compatible) way. The SharedField can be used in any algorithm of the STL that requires random access iterators.
A typical use of the SharedField can be exemplified by the following:
SharedField objects can also be used in for loops like so:
Or directly like so:
While the SharedField objects are not really intended to be created by the user, they are returned by many accessors in the Variant API like the Variant::shared_integer_field() example above. Utilizing them correctly can really simplify your work by leveraging the power of the STL functions.
TYPE | the output type desired for the given tag. For example for AN's typically you would request an int32_t. Conversions are allowed if possible. |
|
inline |
default constructor of an empty SharedField
|
inlineexplicit |
creates a new SharedField pointing to the shared byte array inside the variant object
body | the the bcf1_t structure to hold a shared pointer to |
info_ptr | the info field pointer inside the body |
|
delete |
copying of the SharedField object is not allowed. Use move constructor instead.
|
default |
safely moves the data from one SharedField to a new one without making any copies
|
inline |
convenience function to access the last element
|
inline |
create a new iterator pointing to the begining of the values of this field
|
inline |
checks if the object is empty.
|
inline |
create a new iterator pointing to the end of the values of this field
|
inline |
convenience function to access the first element
|
inline |
simple overload of empty to work with gamgee's missing API
|
inline |
compares two SharedField objects in the following order: memory address, size and values.
other | something to compare to |
|
delete |
copying of the SharedField object is not allowed. Use move constructor instead.
|
default |
safely moves the data from one SharedField to the other without making any copies
|
inline |
compares two SharedField objects in the following order: memory address, size and values.
other | something to compare to |
|
inline |
random access to a given value for reading or writing
index | must be between 0 and the number of values for this record |
std::out_of_range | if index is out of range or entire field is missing and trying to access invalid memory |
|
inline |
|
inline |
the number of values in this SharedField (values per sample)
|
inline |