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_
3
3
4
4
/*
5
5
Genesis - A toolkit for working with phylogenetic data.
@@ -48,23 +48,23 @@ namespace genesis {
48
48
namespace population {
49
49
50
50
// =================================================================================================
51
- // Base Window Iterator
51
+ // Base Window Stream
52
52
// =================================================================================================
53
53
54
54
/* *
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.
56
56
*
57
57
* This base class serves for sliding windows, windows over regions of a genome, etc.
58
58
*
59
59
* 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
63
63
* call the `InputType` (and typedef it as that).
64
64
* * `Data`: The data type of the Window::Data that is stored in Window::Entry. The functor
65
65
* #entry_input_function needs to be provided to convert from `InputType` to this `Data`.
66
66
* 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.
68
68
*
69
69
* The three functors
70
70
*
@@ -74,12 +74,12 @@ namespace population {
74
74
*
75
75
* have to be set in the class prior to starting the iteration.
76
76
*
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 :
79
79
*
80
- * // Make an iterator using some underlying data iterator
80
+ * // Make a window stream using some underlying data stream
81
81
* // 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 );
83
83
*
84
84
* // Set functors to access the underlying data.
85
85
* win_it.entry_input_function = []( Data const& variant ) {
@@ -104,23 +104,23 @@ namespace population {
104
104
* Other derived classes work accordingly.
105
105
*/
106
106
template <
107
- class InputIterator ,
108
- class Data = typename InputIterator ::value_type,
107
+ class InputStreamIterator ,
108
+ class Data = typename InputStreamIterator ::value_type,
109
109
class WindowType = typename ::genesis::population::Window<Data>
110
110
>
111
- class BaseWindowIterator
111
+ class BaseWindowStream
112
112
{
113
113
public:
114
114
115
115
// -------------------------------------------------------------------------
116
116
// Typedefs and Enums
117
117
// -------------------------------------------------------------------------
118
118
119
- using InputIteratorType = InputIterator ;
119
+ using InputStreamType = InputStreamIterator ;
120
120
using DataType = Data;
121
121
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;
124
124
125
125
using iterator_category = std::input_iterator_tag;
126
126
using value_type = WindowType;
@@ -133,19 +133,19 @@ class BaseWindowIterator
133
133
// -------------------------------------------------------------------------
134
134
135
135
/* *
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
137
137
* to fill the windows to the data that is stored per window.
138
138
*/
139
139
std::function<DataType( InputType const & )> entry_input_function;
140
140
141
141
/* *
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.
143
143
*/
144
144
std::function<std::string( InputType const & )> chromosome_function;
145
145
146
146
/* *
147
147
* @brief Functor that yields the current position on the chromosome,
148
- * given the input iterator data.
148
+ * given the input stream data.
149
149
*/
150
150
std::function<size_t ( InputType const & )> position_function;
151
151
@@ -183,10 +183,10 @@ class BaseWindowIterator
183
183
// Constructors and Rule of Five
184
184
// -------------------------------------------------------------------------
185
185
186
- using self_type = typename BaseWindowIterator <
187
- InputIteratorType , DataType, WindowType
186
+ using self_type = typename BaseWindowStream <
187
+ InputStreamType , DataType, WindowType
188
188
>::Iterator;
189
- using InputType = typename InputIteratorType ::value_type;
189
+ using InputType = typename InputStreamType ::value_type;
190
190
191
191
using iterator_category = std::input_iterator_tag;
192
192
using value_type = WindowType;
@@ -228,7 +228,7 @@ class BaseWindowIterator
228
228
return *this ;
229
229
}
230
230
231
- friend BaseWindowIterator ;
231
+ friend BaseWindowStream ;
232
232
233
233
// -------------------------------------------------------------------------
234
234
// Properties
@@ -320,7 +320,7 @@ class BaseWindowIterator
320
320
* Any two iterators that are copies of each other or started from the same parent
321
321
* will compare equal, as long as neither of them is past-the-end.
322
322
* 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.
324
324
* Two past-the-end iterators compare equal.
325
325
*/
326
326
bool operator ==( self_type const & other ) const
@@ -388,10 +388,10 @@ class BaseWindowIterator
388
388
// Constructors and Rule of Five
389
389
// -------------------------------------------------------------------------
390
390
391
- using self_type = typename BaseWindowIterator <
392
- InputIteratorType , DataType, WindowType
391
+ using self_type = typename BaseWindowStream <
392
+ InputStreamType , DataType, WindowType
393
393
>::BaseIterator;
394
- using InputType = typename InputIteratorType ::value_type;
394
+ using InputType = typename InputStreamType ::value_type;
395
395
396
396
using iterator_category = std::input_iterator_tag;
397
397
using value_type = WindowType;
@@ -409,7 +409,7 @@ class BaseWindowIterator
409
409
* @brief Construct the base class, which does initialization checks on its member
410
410
* variables to ensure that the user has set up the functors correctly.
411
411
*/
412
- BaseIterator ( BaseWindowIterator const * parent )
412
+ BaseIterator ( BaseWindowStream const * parent )
413
413
{
414
414
init_ ( parent );
415
415
}
@@ -426,7 +426,7 @@ class BaseWindowIterator
426
426
// BaseIterator& operator= ( self_type const& ) = default;
427
427
// BaseIterator& operator= ( self_type&& ) = default;
428
428
429
- friend BaseWindowIterator ;
429
+ friend BaseWindowStream ;
430
430
friend Iterator;
431
431
432
432
// -------------------------------------------------------------------------
@@ -438,7 +438,7 @@ class BaseWindowIterator
438
438
/* *
439
439
* @brief Initialize the base iterator class and check that it is set up correctly.
440
440
*/
441
- void init_ ( BaseWindowIterator const * parent )
441
+ void init_ ( BaseWindowStream const * parent )
442
442
{
443
443
// We use the parent as a check if this Iterator is intended to be a begin()
444
444
// or end() iterator. If its the former, init. If the latter, we are done here.
@@ -454,19 +454,19 @@ class BaseWindowIterator
454
454
// Check that the functors are set up.
455
455
if ( ! parent->entry_input_function ) {
456
456
throw std::runtime_error (
457
- " Need to set BaseWindowIterator ::entry_input_function "
457
+ " Need to set BaseWindowStream ::entry_input_function "
458
458
" before iterating over Windows with a Window Iterator."
459
459
);
460
460
}
461
461
if ( ! parent->chromosome_function ) {
462
462
throw std::runtime_error (
463
- " Need to set BaseWindowIterator ::chromosome_function "
463
+ " Need to set BaseWindowStream ::chromosome_function "
464
464
" before iterating over Windows with a Window Iterator."
465
465
);
466
466
}
467
467
if ( ! parent->position_function ) {
468
468
throw std::runtime_error (
469
- " Need to set BaseWindowIterator ::position_function "
469
+ " Need to set BaseWindowStream ::position_function "
470
470
" before iterating over Windows with a Window Iterator."
471
471
);
472
472
}
@@ -498,17 +498,17 @@ class BaseWindowIterator
498
498
* In the derived class implementation, this should be a pointer to the _derived_ parent
499
499
* class, to make sure that it contains the correct settings etc needed for the iteration.
500
500
*/
501
- virtual BaseWindowIterator const * get_parent_ () const = 0;
501
+ virtual BaseWindowStream const * get_parent_ () const = 0;
502
502
503
503
protected:
504
504
505
505
// Need to manually keep track of those...
506
506
bool is_first_window_ = true ;
507
507
bool is_last_window_ = false ;
508
508
509
- // Underlying iterator
510
- InputIterator current_;
511
- InputIterator end_;
509
+ // Underlying data stream
510
+ InputStreamIterator current_;
511
+ InputStreamIterator end_;
512
512
513
513
};
514
514
@@ -522,18 +522,18 @@ class BaseWindowIterator
522
522
// Constructors and Rule of Five
523
523
// -------------------------------------------------------------------------
524
524
525
- BaseWindowIterator ( InputIterator begin, InputIterator end )
525
+ BaseWindowStream ( InputStreamIterator begin, InputStreamIterator end )
526
526
: begin_(begin)
527
527
, end_(end)
528
528
{}
529
529
530
- virtual ~BaseWindowIterator () = default ;
530
+ virtual ~BaseWindowStream () = default ;
531
531
532
- BaseWindowIterator ( BaseWindowIterator const & ) = default;
533
- BaseWindowIterator ( BaseWindowIterator && ) = default;
532
+ BaseWindowStream ( BaseWindowStream const & ) = default;
533
+ BaseWindowStream ( BaseWindowStream && ) = default;
534
534
535
- BaseWindowIterator & operator = ( BaseWindowIterator const & ) = default ;
536
- BaseWindowIterator & operator = ( BaseWindowIterator && ) = default ;
535
+ BaseWindowStream & operator = ( BaseWindowStream const & ) = default ;
536
+ BaseWindowStream & operator = ( BaseWindowStream && ) = default ;
537
537
538
538
friend Iterator;
539
539
@@ -588,8 +588,8 @@ class BaseWindowIterator
588
588
589
589
protected:
590
590
591
- // Need a default for WindowViewIterator .
592
- BaseWindowIterator () = default;
591
+ // Need a default for WindowViewStream .
592
+ BaseWindowStream () = default;
593
593
594
594
virtual std::unique_ptr<BaseIterator> get_begin_iterator_ () = 0;
595
595
virtual std::unique_ptr<BaseIterator> get_end_iterator_ () = 0;
@@ -601,8 +601,8 @@ class BaseWindowIterator
601
601
private:
602
602
603
603
// Underlying iterator to the data that we want to put in windows.
604
- InputIterator begin_;
605
- InputIterator end_;
604
+ InputStreamIterator begin_;
605
+ InputStreamIterator end_;
606
606
607
607
// Keep the observers for each window view.
608
608
std::vector<std::function<void (WindowType const &)>> observers_;
0 commit comments