A library for working with phylogenetic and population genetic data.
v0.32.0
WindowViewStream< InputStreamIterator, Data > Class Template Referencefinal

#include <genesis/population/window/window_view_stream.hpp>

Inherits BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type, ::genesis::population::WindowView< typename InputStreamIterator::value_type > >.

Detailed Description

template<class InputStreamIterator, class Data = typename InputStreamIterator::value_type>
class genesis::population::WindowViewStream< InputStreamIterator, Data >

Stream wrapper that turns a BaseWindowStream over Window into a BaseWindowStream over WindowView.

This serves as an abstraction to be able to use WindowViewStream everywhere, instead of having to switch between WindowViewStream and WindowStream depending on the type of windowing that is being done. For example, SlidingIntervalWindowStream, SlidingEntriesWindowStream, and RegionWindowStream yield streams over Windows, while the ChromosomeStream (and the whole genome stream that can be created with it as well) yield streams over WindowViews instead. This makes it cumbersome to switch between the two types downstream. Hence, yet another abstraction.

In more technical terms, some of our window streams are inheriting from BaseWindowStream<InputStreamIterator, Data, Window>, while others are inheriting from BaseWindowStream<InputStreamIterator, Data, WindowView>, making their base classes incompatible, so that they cannot be assigned to the same pointer variable. This class here solves this, by wrapping the former into a class derived from the latter, and hence using the latter type as the one that we can use for uniform access to window streams.

The class takes the BaseWindowStream to be iterated over as input, and iteraters its windows, and then simply wraps them into a WindowView whose elements point to these windows.

Definition at line 74 of file window_view_stream.hpp.

Public Member Functions

 WindowViewStream (std::unique_ptr< WrappedWindowStream > window_iterator)
 
 WindowViewStream (WindowViewStream &&)=default
 
 WindowViewStream (WindowViewStream const &)=default
 
virtual ~WindowViewStream () override=default
 
WindowViewStreamoperator= (WindowViewStream &&)=default
 
WindowViewStreamoperator= (WindowViewStream const &)=default
 
- Public Member Functions inherited from BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type, ::genesis::population::WindowView< typename InputStreamIterator::value_type > >
 BaseWindowStream (BaseWindowStream &&)=default
 
 BaseWindowStream (BaseWindowStream const &)=default
 
 BaseWindowStream (InputStreamIterator begin, InputStreamIterator end)
 
virtual ~BaseWindowStream ()=default
 
self_typeadd_begin_callback (std::function< void()> const &callback)
 Add a callback function that is executed when beginning the iteration. More...
 
self_typeadd_end_callback (std::function< void()> const &callback)
 Add a callback function that is executed when the end of the iteration is reached. More...
 
self_typeadd_on_enter_observer (std::function< void(::genesis::population::WindowView< typename InputStreamIterator::value_type > const &)> const &observer)
 Add a observer function that is executed once for each window during the iteration, when entering the window during the iteration. More...
 
self_typeadd_on_leave_observer (std::function< void(::genesis::population::WindowView< typename InputStreamIterator::value_type > const &)> const &observer)
 Add a observer function that is executed once for each window during the iteration, when leaving the window during the iteration. More...
 
Iterator begin ()
 
self_typeclear_callbacks ()
 Clear all functions that have been added via add_begin_callback() and add_end_callback(). More...
 
self_typeclear_observers ()
 Clear all functions that are executed on incrementing to the next element. More...
 
Iterator end ()
 
BaseWindowStreamoperator= (BaseWindowStream &&)=default
 
BaseWindowStreamoperator= (BaseWindowStream const &)=default
 

Public Types

using base_type = BaseWindowStream< InputStreamType, DataType, WindowViewType >
 
using const_reference = value_type const &
 
using DataType = Data
 
using InputStreamType = InputStreamIterator
 
using InputType = typename InputStreamIterator::value_type
 
using iterator_category = std::input_iterator_tag
 
using pointer = value_type *
 
using reference = value_type &
 
using self_type = WindowViewStream< InputStreamType, DataType >
 
using value_type = WindowViewType
 
using WindowType = ::genesis::population::WindowView< DataType >
 
using WindowViewType = WindowType
 
using WrappedWindowStream = BaseWindowStream< InputStreamType, DataType >
 
using WrappedWindowStreamIterator = typename WrappedWindowStream::Iterator
 
- Public Types inherited from BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type, ::genesis::population::WindowView< typename InputStreamIterator::value_type > >
using const_reference = value_type const &
 
using DataType = typename InputStreamIterator::value_type
 
using InputStreamType = InputStreamIterator
 
using InputType = typename InputStreamIterator::value_type
 
using iterator_category = std::input_iterator_tag
 
using pointer = value_type *
 
using reference = value_type &
 
using self_type = BaseWindowStream< InputStreamIterator, DataType, ::genesis::population::WindowView< typename InputStreamIterator::value_type > >
 
using value_type = ::genesis::population::WindowView< typename InputStreamIterator::value_type >
 

Public Attributes

friend DerivedIterator
 
- Public Attributes inherited from BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type, ::genesis::population::WindowView< typename InputStreamIterator::value_type > >
std::function< std::string(InputType const &)> chromosome_function
 Functor that yields the current chromosome, given the input stream data. More...
 
std::function< DataType(InputType const &)> entry_input_function
 Functor to convert from the underlying input stream that provides the data to fill the windows to the data that is stored per window. More...
 
friend Iterator
 
std::function< size_t(InputType const &)> position_function
 Functor that yields the current position on the chromosome, given the input stream data. More...
 

Classes

class  DerivedIterator
 Internal iterator that produces WindowViews. More...
 

Protected Member Functions

std::unique_ptr< typename base_type::BaseIteratorget_begin_iterator_ () override final
 Get the begin iterator. More...
 
std::unique_ptr< typename base_type::BaseIteratorget_end_iterator_ () override final
 Get the end iterator. More...
 
- Protected Member Functions inherited from BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type, ::genesis::population::WindowView< typename InputStreamIterator::value_type > >
 BaseWindowStream ()=default
 

Constructor & Destructor Documentation

◆ WindowViewStream() [1/3]

WindowViewStream ( std::unique_ptr< WrappedWindowStream window_iterator)
inline

Definition at line 253 of file window_view_stream.hpp.

◆ ~WindowViewStream()

virtual ~WindowViewStream ( )
overridevirtualdefault

◆ WindowViewStream() [2/3]

WindowViewStream ( WindowViewStream< InputStreamIterator, Data > const &  )
default

◆ WindowViewStream() [3/3]

WindowViewStream ( WindowViewStream< InputStreamIterator, Data > &&  )
default

Member Function Documentation

◆ get_begin_iterator_()

std::unique_ptr<typename base_type::BaseIterator> get_begin_iterator_ ( )
inlinefinaloverrideprotectedvirtual

Get the begin iterator.

Needs to be implemented by the derived class, to give the correct derived BaseIterator instance.

Implements BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type, ::genesis::population::WindowView< typename InputStreamIterator::value_type > >.

Definition at line 276 of file window_view_stream.hpp.

◆ get_end_iterator_()

std::unique_ptr<typename base_type::BaseIterator> get_end_iterator_ ( )
inlinefinaloverrideprotectedvirtual

Get the end iterator.

Needs to be implemented by the derived class, to give the correct derived BaseIterator instance.

Implements BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type, ::genesis::population::WindowView< typename InputStreamIterator::value_type > >.

Definition at line 285 of file window_view_stream.hpp.

◆ operator=() [1/2]

WindowViewStream& operator= ( WindowViewStream< InputStreamIterator, Data > &&  )
default

◆ operator=() [2/2]

WindowViewStream& operator= ( WindowViewStream< InputStreamIterator, Data > const &  )
default

Member Typedef Documentation

◆ base_type

◆ const_reference

using const_reference = value_type const&

Definition at line 109 of file window_view_stream.hpp.

◆ DataType

using DataType = Data

Definition at line 85 of file window_view_stream.hpp.

◆ InputStreamType

using InputStreamType = InputStreamIterator

Definition at line 84 of file window_view_stream.hpp.

◆ InputType

using InputType = typename InputStreamIterator::value_type

Definition at line 99 of file window_view_stream.hpp.

◆ iterator_category

using iterator_category = std::input_iterator_tag

Definition at line 105 of file window_view_stream.hpp.

◆ pointer

using pointer = value_type*

Definition at line 107 of file window_view_stream.hpp.

◆ reference

Definition at line 108 of file window_view_stream.hpp.

◆ self_type

◆ value_type

Definition at line 106 of file window_view_stream.hpp.

◆ WindowType

◆ WindowViewType

Definition at line 87 of file window_view_stream.hpp.

◆ WrappedWindowStream

◆ WrappedWindowStreamIterator

Member Data Documentation

◆ DerivedIterator

Definition at line 267 of file window_view_stream.hpp.


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