A library for working with phylogenetic and population genetic data.
v0.32.0
BaseInputSource Class Referenceabstract

#include <genesis/utils/io/base_input_source.hpp>

Inherited by FileInputSource, GzipInputSource, StreamInputSource, and StringInputSource.

Detailed Description

Abstract base class for reading byte data from input sources.

It offers to read() a certain amount of bytes into a char buffer.

Definition at line 50 of file base_input_source.hpp.

Public Member Functions

 BaseInputSource ()=default
 
 BaseInputSource (BaseInputSource &&)=default
 
 BaseInputSource (BaseInputSource const &)=default
 
virtual ~BaseInputSource ()
 
bool is_trivial () const
 Return whether reading from this source is trivial, such as reading from a file, or involves more complex operations, such as reading from a compressed input that needs to be decompressed first. More...
 
BaseInputSourceoperator= (BaseInputSource &&)=default
 
BaseInputSourceoperator= (BaseInputSource const &)=default
 
size_t read (char *buffer, size_t size)
 Read size many bytes into the char buffer. More...
 
std::string source_name () const
 Get a name of the input source. This is intended for user output. More...
 
std::string source_string () const
 Get a string representing the input source. This is intended for the reader classes, which for example might want to examine the input file name. More...
 

Constructor & Destructor Documentation

◆ BaseInputSource() [1/3]

BaseInputSource ( )
default

◆ BaseInputSource() [2/3]

BaseInputSource ( BaseInputSource const &  )
default

◆ BaseInputSource() [3/3]

BaseInputSource ( BaseInputSource &&  )
default

◆ ~BaseInputSource()

virtual ~BaseInputSource ( )
inlinevirtual

Definition at line 66 of file base_input_source.hpp.

Member Function Documentation

◆ is_trivial()

bool is_trivial ( ) const
inline

Return whether reading from this source is trivial, such as reading from a file, or involves more complex operations, such as reading from a compressed input that needs to be decompressed first.

This helps downstream processes to decide if reading can be done in a cheap async thread, or needs to use the global thread pool in order to not oversubscribe the system when many such inputs (e.g., many gzipped files) are read in parallel. A thread that is just reading a block of data from a file is not using computation, and will spend its time in I/O wait, so it's okay to have many of those. However, compressed files need computation, and are hence not trivial.

Definition at line 116 of file base_input_source.hpp.

◆ operator=() [1/2]

BaseInputSource& operator= ( BaseInputSource &&  )
default

◆ operator=() [2/2]

BaseInputSource& operator= ( BaseInputSource const &  )
default

◆ read()

size_t read ( char *  buffer,
size_t  size 
)
inline

Read size many bytes into the char buffer.

Returns the number of bytes that have actually been read, which might be lower than the initial target size, e.g., if the end of the input source was reached.

Definition at line 79 of file base_input_source.hpp.

◆ source_name()

std::string source_name ( ) const
inline

Get a name of the input source. This is intended for user output.

Definition at line 88 of file base_input_source.hpp.

◆ source_string()

std::string source_string ( ) const
inline

Get a string representing the input source. This is intended for the reader classes, which for example might want to examine the input file name.

Definition at line 98 of file base_input_source.hpp.


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