Skip to content

Commit 0e0024e

Browse files
committed
Rename all Window Iterators into Streams
1 parent 2bf4bd8 commit 0e0024e

18 files changed

+478
-478
lines changed

lib/genesis/population.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@
8181
#include "genesis/population/streams/variant_parallel_input_stream.hpp"
8282
#include "genesis/population/variant.hpp"
8383
#include "genesis/population/window/base_window.hpp"
84-
#include "genesis/population/window/base_window_iterator.hpp"
85-
#include "genesis/population/window/chromosome_iterator.hpp"
84+
#include "genesis/population/window/base_window_stream.hpp"
85+
#include "genesis/population/window/chromosome_stream.hpp"
8686
#include "genesis/population/window/functions.hpp"
87-
#include "genesis/population/window/region_window_iterator.hpp"
88-
#include "genesis/population/window/sliding_entries_window_iterator.hpp"
89-
#include "genesis/population/window/sliding_interval_window_iterator.hpp"
87+
#include "genesis/population/window/region_window_stream.hpp"
88+
#include "genesis/population/window/sliding_entries_window_stream.hpp"
89+
#include "genesis/population/window/sliding_interval_window_stream.hpp"
9090
#include "genesis/population/window/sliding_window_generator.hpp"
91-
#include "genesis/population/window/variant_window_iterator.hpp"
91+
#include "genesis/population/window/variant_window_stream.hpp"
9292
#include "genesis/population/window/vcf_window.hpp"
9393
#include "genesis/population/window/window.hpp"
9494
#include "genesis/population/window/window_view.hpp"
95-
#include "genesis/population/window/window_view_iterator.hpp"
95+
#include "genesis/population/window/window_view_stream.hpp"
9696

9797
#endif // include guard

lib/genesis/population/window/base_window_iterator.hpp renamed to lib/genesis/population/window/base_window_stream.hpp

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef GENESIS_POPULATION_WINDOW_BASE_WINDOW_ITERATOR_H_
2-
#define GENESIS_POPULATION_WINDOW_BASE_WINDOW_ITERATOR_H_
1+
#ifndef GENESIS_POPULATION_WINDOW_BASE_WINDOW_STREAM_H_
2+
#define GENESIS_POPULATION_WINDOW_BASE_WINDOW_STREAM_H_
33

44
/*
55
Genesis - A toolkit for working with phylogenetic data.
@@ -48,23 +48,23 @@ namespace genesis {
4848
namespace population {
4949

5050
// =================================================================================================
51-
// Base Window Iterator
51+
// Base Window Stream
5252
// =================================================================================================
5353

5454
/**
55-
* @brief Base iterator class for Window%s over the chromosomes of a genome.
55+
* @brief Base class for streams of Window%s over the chromosomes of a genome.
5656
*
5757
* This base class serves for sliding windows, windows over regions of a genome, etc.
5858
*
5959
* The template parameters are:
60-
* * `InputIterator`: The type of the underlying iterator over the genome data (that is, the input
61-
* iterator from which the windows take their data). Needs to have a member type
62-
* `value_type` that specifies the actual input type that the iterator produces, which we here
60+
* * `InputStreamIterator`: The type of the underlying stream over the genome data (that is, the input
61+
* stream from which the windows take their data). Needs to have a member type
62+
* `value_type` that specifies the actual input type that the stream produces, which we here
6363
* call the `InputType` (and typedef it as that).
6464
* * `Data`: The data type of the Window::Data that is stored in Window::Entry. The functor
6565
* #entry_input_function needs to be provided to convert from `InputType` to this `Data`.
6666
* By default, we take this to be the same as the `InputType`, meaning that the Window contains
67-
* the same data type as the underlying iterator that we get our data from.
67+
* the same data type as the underlying stream that we get our data from.
6868
*
6969
* The three functors
7070
*
@@ -74,12 +74,12 @@ namespace population {
7474
*
7575
* have to be set in the class prior to starting the iteration.
7676
*
77-
* The general usage of the derived classes that actually implement this iterator is as follows,
78-
* on the example of the SlidingIntervalWindowIterator:
77+
* The general usage of the derived classes that actually implement this stream is as follows,
78+
* on the example of the SlidingIntervalWindowStream:
7979
*
80-
* // Make an iterator using some underlying data iterator
80+
* // Make a window stream using some underlying data stream
8181
* // that yields data for one position in the genome at a time.
82-
* auto win_it = SlidingIntervalWindowIterator<InputIterator>( data_begin, data_end );
82+
* auto win_it = SlidingIntervalWindowStream<InputStreamIterator>( data_begin, data_end );
8383
*
8484
* // Set functors to access the underlying data.
8585
* win_it.entry_input_function = []( Data const& variant ) {
@@ -104,23 +104,23 @@ namespace population {
104104
* Other derived classes work accordingly.
105105
*/
106106
template<
107-
class InputIterator,
108-
class Data = typename InputIterator::value_type,
107+
class InputStreamIterator,
108+
class Data = typename InputStreamIterator::value_type,
109109
class WindowType = typename ::genesis::population::Window<Data>
110110
>
111-
class BaseWindowIterator
111+
class BaseWindowStream
112112
{
113113
public:
114114

115115
// -------------------------------------------------------------------------
116116
// Typedefs and Enums
117117
// -------------------------------------------------------------------------
118118

119-
using InputIteratorType = InputIterator;
119+
using InputStreamType = InputStreamIterator;
120120
using DataType = Data;
121121

122-
using self_type = BaseWindowIterator<InputIterator, DataType, WindowType>;
123-
using InputType = typename InputIterator::value_type;
122+
using self_type = BaseWindowStream<InputStreamIterator, DataType, WindowType>;
123+
using InputType = typename InputStreamIterator::value_type;
124124

125125
using iterator_category = std::input_iterator_tag;
126126
using value_type = WindowType;
@@ -133,19 +133,19 @@ class BaseWindowIterator
133133
// -------------------------------------------------------------------------
134134

135135
/**
136-
* @brief Functor to convert from the underlying input iterator that provides the data
136+
* @brief Functor to convert from the underlying input stream that provides the data
137137
* to fill the windows to the data that is stored per window.
138138
*/
139139
std::function<DataType( InputType const& )> entry_input_function;
140140

141141
/**
142-
* @brief Functor that yields the current chromosome, given the input iterator data.
142+
* @brief Functor that yields the current chromosome, given the input stream data.
143143
*/
144144
std::function<std::string( InputType const& )> chromosome_function;
145145

146146
/**
147147
* @brief Functor that yields the current position on the chromosome,
148-
* given the input iterator data.
148+
* given the input stream data.
149149
*/
150150
std::function<size_t( InputType const& )> position_function;
151151

@@ -183,10 +183,10 @@ class BaseWindowIterator
183183
// Constructors and Rule of Five
184184
// -------------------------------------------------------------------------
185185

186-
using self_type = typename BaseWindowIterator<
187-
InputIteratorType, DataType, WindowType
186+
using self_type = typename BaseWindowStream<
187+
InputStreamType, DataType, WindowType
188188
>::Iterator;
189-
using InputType = typename InputIteratorType::value_type;
189+
using InputType = typename InputStreamType::value_type;
190190

191191
using iterator_category = std::input_iterator_tag;
192192
using value_type = WindowType;
@@ -228,7 +228,7 @@ class BaseWindowIterator
228228
return *this;
229229
}
230230

231-
friend BaseWindowIterator;
231+
friend BaseWindowStream;
232232

233233
// -------------------------------------------------------------------------
234234
// Properties
@@ -320,7 +320,7 @@ class BaseWindowIterator
320320
* Any two iterators that are copies of each other or started from the same parent
321321
* will compare equal, as long as neither of them is past-the-end.
322322
* A valid (not past-the-end) iterator and an end() iterator will not compare equal,
323-
* no matter from which BaseWindowIterator they were created.
323+
* no matter from which BaseWindowStream they were created.
324324
* Two past-the-end iterators compare equal.
325325
*/
326326
bool operator==( self_type const& other ) const
@@ -388,10 +388,10 @@ class BaseWindowIterator
388388
// Constructors and Rule of Five
389389
// -------------------------------------------------------------------------
390390

391-
using self_type = typename BaseWindowIterator<
392-
InputIteratorType, DataType, WindowType
391+
using self_type = typename BaseWindowStream<
392+
InputStreamType, DataType, WindowType
393393
>::BaseIterator;
394-
using InputType = typename InputIteratorType::value_type;
394+
using InputType = typename InputStreamType::value_type;
395395

396396
using iterator_category = std::input_iterator_tag;
397397
using value_type = WindowType;
@@ -409,7 +409,7 @@ class BaseWindowIterator
409409
* @brief Construct the base class, which does initialization checks on its member
410410
* variables to ensure that the user has set up the functors correctly.
411411
*/
412-
BaseIterator( BaseWindowIterator const* parent )
412+
BaseIterator( BaseWindowStream const* parent )
413413
{
414414
init_( parent );
415415
}
@@ -426,7 +426,7 @@ class BaseWindowIterator
426426
// BaseIterator& operator= ( self_type const& ) = default;
427427
// BaseIterator& operator= ( self_type&& ) = default;
428428

429-
friend BaseWindowIterator;
429+
friend BaseWindowStream;
430430
friend Iterator;
431431

432432
// -------------------------------------------------------------------------
@@ -438,7 +438,7 @@ class BaseWindowIterator
438438
/**
439439
* @brief Initialize the base iterator class and check that it is set up correctly.
440440
*/
441-
void init_( BaseWindowIterator const* parent )
441+
void init_( BaseWindowStream const* parent )
442442
{
443443
// We use the parent as a check if this Iterator is intended to be a begin()
444444
// or end() iterator. If its the former, init. If the latter, we are done here.
@@ -454,19 +454,19 @@ class BaseWindowIterator
454454
// Check that the functors are set up.
455455
if( ! parent->entry_input_function ) {
456456
throw std::runtime_error(
457-
"Need to set BaseWindowIterator::entry_input_function "
457+
"Need to set BaseWindowStream::entry_input_function "
458458
"before iterating over Windows with a Window Iterator."
459459
);
460460
}
461461
if( ! parent->chromosome_function ) {
462462
throw std::runtime_error(
463-
"Need to set BaseWindowIterator::chromosome_function "
463+
"Need to set BaseWindowStream::chromosome_function "
464464
"before iterating over Windows with a Window Iterator."
465465
);
466466
}
467467
if( ! parent->position_function ) {
468468
throw std::runtime_error(
469-
"Need to set BaseWindowIterator::position_function "
469+
"Need to set BaseWindowStream::position_function "
470470
"before iterating over Windows with a Window Iterator."
471471
);
472472
}
@@ -498,17 +498,17 @@ class BaseWindowIterator
498498
* In the derived class implementation, this should be a pointer to the _derived_ parent
499499
* class, to make sure that it contains the correct settings etc needed for the iteration.
500500
*/
501-
virtual BaseWindowIterator const* get_parent_() const = 0;
501+
virtual BaseWindowStream const* get_parent_() const = 0;
502502

503503
protected:
504504

505505
// Need to manually keep track of those...
506506
bool is_first_window_ = true;
507507
bool is_last_window_ = false;
508508

509-
// Underlying iterator
510-
InputIterator current_;
511-
InputIterator end_;
509+
// Underlying data stream
510+
InputStreamIterator current_;
511+
InputStreamIterator end_;
512512

513513
};
514514

@@ -522,18 +522,18 @@ class BaseWindowIterator
522522
// Constructors and Rule of Five
523523
// -------------------------------------------------------------------------
524524

525-
BaseWindowIterator( InputIterator begin, InputIterator end )
525+
BaseWindowStream( InputStreamIterator begin, InputStreamIterator end )
526526
: begin_(begin)
527527
, end_(end)
528528
{}
529529

530-
virtual ~BaseWindowIterator() = default;
530+
virtual ~BaseWindowStream() = default;
531531

532-
BaseWindowIterator( BaseWindowIterator const& ) = default;
533-
BaseWindowIterator( BaseWindowIterator&& ) = default;
532+
BaseWindowStream( BaseWindowStream const& ) = default;
533+
BaseWindowStream( BaseWindowStream&& ) = default;
534534

535-
BaseWindowIterator& operator= ( BaseWindowIterator const& ) = default;
536-
BaseWindowIterator& operator= ( BaseWindowIterator&& ) = default;
535+
BaseWindowStream& operator= ( BaseWindowStream const& ) = default;
536+
BaseWindowStream& operator= ( BaseWindowStream&& ) = default;
537537

538538
friend Iterator;
539539

@@ -588,8 +588,8 @@ class BaseWindowIterator
588588

589589
protected:
590590

591-
// Need a default for WindowViewIterator.
592-
BaseWindowIterator() = default;
591+
// Need a default for WindowViewStream.
592+
BaseWindowStream() = default;
593593

594594
virtual std::unique_ptr<BaseIterator> get_begin_iterator_() = 0;
595595
virtual std::unique_ptr<BaseIterator> get_end_iterator_() = 0;
@@ -601,8 +601,8 @@ class BaseWindowIterator
601601
private:
602602

603603
// Underlying iterator to the data that we want to put in windows.
604-
InputIterator begin_;
605-
InputIterator end_;
604+
InputStreamIterator begin_;
605+
InputStreamIterator end_;
606606

607607
// Keep the observers for each window view.
608608
std::vector<std::function<void(WindowType const&)>> observers_;

0 commit comments

Comments
 (0)