A library for working with phylogenetic and population genetic data.
v0.32.0
base_window_stream.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_POPULATION_WINDOW_BASE_WINDOW_STREAM_H_
2 #define GENESIS_POPULATION_WINDOW_BASE_WINDOW_STREAM_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2024 Lucas Czech
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lucas.czech@sund.ku.dk>
23  University of Copenhagen, Globe Institute, Section for GeoGenetics
24  Oster Voldgade 5-7, 1350 Copenhagen K, Denmark
25 */
26 
37 
38 #include <cassert>
39 #include <functional>
40 #include <memory>
41 #include <stdexcept>
42 #include <string>
43 #include <type_traits>
44 #include <utility>
45 #include <vector>
46 
47 namespace genesis {
48 namespace population {
49 
50 // =================================================================================================
51 // Base Window Stream
52 // =================================================================================================
53 
114 template<
115  class InputStreamIterator,
116  class Data = typename InputStreamIterator::value_type,
117  class WindowType = typename ::genesis::population::Window<Data>
118 >
120 {
121 public:
122 
123  // -------------------------------------------------------------------------
124  // Typedefs and Enums
125  // -------------------------------------------------------------------------
126 
127  using InputStreamType = InputStreamIterator;
128  using DataType = Data;
129 
131  using InputType = typename InputStreamIterator::value_type;
132 
133  using iterator_category = std::input_iterator_tag;
134  using value_type = WindowType;
135  using pointer = value_type*;
137  using const_reference = value_type const&;
138 
139  // -------------------------------------------------------------------------
140  // Public Functors
141  // -------------------------------------------------------------------------
142 
147  std::function<DataType( InputType const& )> entry_input_function;
148 
152  std::function<std::string( InputType const& )> chromosome_function;
153 
158  std::function<size_t( InputType const& )> position_function;
159 
160  // ======================================================================================
161  // Internal Public Iterator
162  // ======================================================================================
163 
164 protected:
165 
166  // Forward Declaration.
167  class BaseIterator;
168 
169 public:
170 
186  class Iterator final
187  {
188  public:
189 
190  // -------------------------------------------------------------------------
191  // Constructors and Rule of Five
192  // -------------------------------------------------------------------------
193 
194  using self_type = typename BaseWindowStream<
195  InputStreamType, DataType, WindowType
197  using InputType = typename InputStreamType::value_type;
198 
199  using iterator_category = std::input_iterator_tag;
200  using value_type = WindowType;
201  using pointer = value_type*;
203  using const_reference = value_type const&;
204 
205  static_assert( std::is_same<Iterator, self_type>::value, "Iterator != self_type" );
206 
207  protected:
208 
209  // Iterator() = delete;
210 
212  BaseWindowStream const* parent,
213  std::unique_ptr<BaseIterator> base_iterator
214  )
215  : base_parent_( parent )
216  , pimpl_( std::move( base_iterator ))
217  {
218  // Observe the first element, if this is an active iterator.
219  assert( pimpl_ );
220 
221  // If we are here from an end iterator, we do nothing.
222  if( !base_parent_ ) {
223  return;
224  }
225  assert( base_parent_ );
226 
227  // Before starting to init anything, call the callbacks.
228  execute_begin_callbacks_();
229  execute_on_enter_observers_();
230 
231  // Special case: no data. Need to execute the end callback as well.
232  assert( pimpl_ );
233  if( !pimpl_->get_parent_() ) {
234  execute_end_callbacks_();
235  }
236  }
237 
238  public:
239 
240  Iterator() = default;
241  ~Iterator() = default;
242 
243  Iterator( Iterator const& ) = delete;
244  Iterator( Iterator&& other )
245  {
246  // Copy the base parent pointer, as that instance stays the same.
247  // We however need to move the pimpl, as we own it.
248  base_parent_ = other.base_parent_;
249  pimpl_ = std::move( other.pimpl_ );
250 
251  // Now reset the other, so that in case of a bug here, we induce a segfault
252  // instead of accidental undefined behaviour when accessing the old data.
253  other.base_parent_ = nullptr;
254  other.pimpl_ = nullptr;
255  }
256 
257  Iterator& operator= ( Iterator const& ) = delete;
259  {
260  // Same as above.
261  // Probably we should follow the rule of five more closely here though,
262  // and implement one in terms of the other...
263  base_parent_ = other.base_parent_;
264  pimpl_ = std::move( other.pimpl_ );
265  other.base_parent_ = nullptr;
266  other.pimpl_ = nullptr;
267  return *this;
268  }
269 
271 
272  // -------------------------------------------------------------------------
273  // Properties
274  // -------------------------------------------------------------------------
275 
286  bool is_first_window() const
287  {
288  assert( pimpl_ );
289  return pimpl_->is_first_window_;
290  }
291 
302  bool is_last_window() const
303  {
304  assert( pimpl_ );
305  return pimpl_->is_last_window_;
306  }
307 
308  // -------------------------------------------------------------------------
309  // Accessors
310  // -------------------------------------------------------------------------
311 
312  value_type const & operator*() const
313  {
314  assert( pimpl_ );
315  return pimpl_->get_current_window_();
316  }
317 
319  {
320  assert( pimpl_ );
321  return pimpl_->get_current_window_();
322  }
323 
324  value_type const * operator->() const
325  {
326  assert( pimpl_ );
327  return &( pimpl_->get_current_window_() );
328  }
329 
331  {
332  assert( pimpl_ );
333  return &( pimpl_->get_current_window_() );
334  }
335 
336  // -------------------------------------------------------------------------
337  // Iteration
338  // -------------------------------------------------------------------------
339 
341  {
342  assert( pimpl_ );
343  assert( base_parent_ );
344 
345  // Advance to the next element, and observe it.
346  // This is the only place that we need to call the leaving observers:
347  // During normal iteration, this works fine anyway. Then, the last iteration
348  // will first call the leaving oberservers, then try to move to the next window,
349  // but find that there is none, and finish the iteration. By that time, the
350  // leaving oberserver has been called correclty already, so nothing else to do.
351 
352  execute_on_leave_observers_();
353  pimpl_->increment_();
354 
355  // Now that we are at the new element, we execute the enter observers.
356  // If we instead reached the end of the input though, that one will do nothing.
357  // In that case however, we want to execute the end callbacks instead.
358  execute_on_enter_observers_();
359 
360  assert( pimpl_ );
361  assert( base_parent_ );
362  if( !pimpl_->get_parent_() ) {
363  execute_end_callbacks_();
364  }
365  return *this;
366  }
367 
368  // self_type operator ++(int)
369  // {
370  // auto cpy = *this;
371  // increment_();
372  // return cpy;
373  // }
374 
384  bool operator==( self_type const& other ) const
385  {
386  assert( pimpl_ );
387  assert( other.pimpl_ );
388 
389  // We compare the parents as a baseline - two past-the-end iterator shall
390  // always compare equal. If only one of them is past-the-end, they will compare false.
391  return pimpl_->get_parent_() == other.pimpl_->get_parent_();
392  }
393 
394  bool operator!=( self_type const& other ) const
395  {
396  return !(*this == other);
397  }
398 
399  // -------------------------------------------------------------------------
400  // Internal and Virtual Members
401  // -------------------------------------------------------------------------
402 
403  private:
404 
405  void execute_on_enter_observers_()
406  {
407  // If there is still a parent, we are active,
408  // and execute all observers for the window.
409  assert( pimpl_ );
410  if( pimpl_->get_parent_() ) {
411  auto& window = pimpl_->get_current_window_();
412  for( auto const& observer : pimpl_->get_parent_()->on_enter_observers_ ) {
413  observer( window );
414  }
415  }
416  }
417 
418  void execute_on_leave_observers_()
419  {
420  // If there is still a parent, we are active,
421  // and execute all observers for the window.
422  assert( pimpl_ );
423  if( pimpl_->get_parent_() ) {
424  auto& window = pimpl_->get_current_window_();
425  for( auto const& observer : pimpl_->get_parent_()->on_leave_observers_ ) {
426  observer( window );
427  }
428  }
429  }
430 
431  void execute_begin_callbacks_() const
432  {
433  assert( base_parent_ );
434  for( auto const& cb : base_parent_->begin_callbacks_ ) {
435  cb();
436  }
437  }
438 
439  void execute_end_callbacks_() const
440  {
441  assert( base_parent_ );
442  for( auto const& cb : base_parent_->end_callbacks_ ) {
443  cb();
444  }
445  }
446 
447  // -------------------------------------------------------------------------
448  // PIMPL-like Implementation Abstraction
449  // -------------------------------------------------------------------------
450 
451  private:
452 
453  // Parent. This is only the base class, and hence cannot be used by the derived classes.
454  // We need it here for the begin and end callbacks only, as those need to be run
455  // indepentently of the derived classes.
456  BaseWindowStream const* base_parent_ = nullptr;
457 
458  // Implementation of the derived iterator. This is where all the logic for the actual
459  // window iteration lives. We use the pimpl idiom here so that this class here does
460  // not need to expose derived interfaces.
461  std::unique_ptr<BaseIterator> pimpl_;
462 
463  };
464 
465  // ======================================================================================
466  // Internal Base Iterator for PIMPL-like Abstraction
467  // ======================================================================================
468 
469 protected:
470 
479  {
480  public:
481 
482  // -------------------------------------------------------------------------
483  // Constructors and Rule of Five
484  // -------------------------------------------------------------------------
485 
486  using self_type = typename BaseWindowStream<
487  InputStreamType, DataType, WindowType
489  using InputType = typename InputStreamType::value_type;
490 
491  using iterator_category = std::input_iterator_tag;
492  using value_type = WindowType;
493  using pointer = value_type*;
495  using const_reference = value_type const&;
496 
497  static_assert( std::is_same<BaseIterator, self_type>::value, "BaseIterator != self_type" );
498 
499  protected:
500 
501  BaseIterator() = default;
502 
508  {
509  init_( parent );
510  }
511 
512  public:
513 
514  virtual ~BaseIterator() = default;
515 
516  // Abstract base class. Cannot be defaulted, and there is no need to.
517  // We leave that to the implementations.
518  //
519  // BaseIterator( self_type const& ) = default;
520  // BaseIterator( self_type&& ) = default;
521  // BaseIterator& operator= ( self_type const& ) = default;
522  // BaseIterator& operator= ( self_type&& ) = default;
523 
525  friend Iterator;
526 
527  // -------------------------------------------------------------------------
528  // Internal Members
529  // -------------------------------------------------------------------------
530 
531  protected:
532 
536  void init_( BaseWindowStream const* parent )
537  {
538  // We use the parent as a check if this Iterator is intended to be a begin()
539  // or end() iterator. If its the former, init. If the latter, we are done here.
540  // After we are done iterating the input (for which we do need _its_ begin and end
541  // iterators), we then set the parent_ to nullptr, as a sign that we are done.
542  // This allows us also to know if we reached end() (of the window iteration;
543  // not of the underlying data iterator) without having to store the end() iterator
544  // when using this class.
545  if( ! parent ) {
546  return;
547  }
548 
549  // Check that the functors are set up.
550  if( ! parent->entry_input_function ) {
551  throw std::runtime_error(
552  "Need to set BaseWindowStream::entry_input_function "
553  "before iterating over Windows with a Window Iterator."
554  );
555  }
556  if( ! parent->chromosome_function ) {
557  throw std::runtime_error(
558  "Need to set BaseWindowStream::chromosome_function "
559  "before iterating over Windows with a Window Iterator."
560  );
561  }
562  if( ! parent->position_function ) {
563  throw std::runtime_error(
564  "Need to set BaseWindowStream::position_function "
565  "before iterating over Windows with a Window Iterator."
566  );
567  }
568 
569  // Copy over the underlying data iterator.
570  current_ = parent->begin_;
571  end_ = parent->end_;
572  }
573 
574  // -------------------------------------------------------------------------
575  // Virtual Members
576  // -------------------------------------------------------------------------
577 
578  protected:
579 
583  virtual void increment_() = 0;
584 
588  virtual value_type& get_current_window_() const = 0;
589 
596  virtual BaseWindowStream const* get_parent_() const = 0;
597 
598  protected:
599 
600  // Need to manually keep track of those...
601  bool is_first_window_ = true;
602  bool is_last_window_ = false;
603 
604  // Underlying data stream
605  InputStreamIterator current_;
606  InputStreamIterator end_;
607 
608  };
609 
610  // ======================================================================================
611  // Main Class
612  // ======================================================================================
613 
614 public:
615 
616  // -------------------------------------------------------------------------
617  // Constructors and Rule of Five
618  // -------------------------------------------------------------------------
619 
620  BaseWindowStream( InputStreamIterator begin, InputStreamIterator end )
621  : begin_(begin)
622  , end_(end)
623  {}
624 
625  virtual ~BaseWindowStream() = default;
626 
627  BaseWindowStream( BaseWindowStream const& ) = default;
628  BaseWindowStream( BaseWindowStream&& ) = default;
629 
630  BaseWindowStream& operator= ( BaseWindowStream const& ) = default;
632 
633  friend Iterator;
634 
635  // -------------------------------------------------------------------------
636  // Observers
637  // -------------------------------------------------------------------------
638 
652  self_type& add_on_enter_observer( std::function<void(WindowType const&)> const& observer )
653  {
654  on_enter_observers_.push_back( observer );
655  return *this;
656  }
657 
671  self_type& add_on_leave_observer( std::function<void(WindowType const&)> const& observer )
672  {
673  on_leave_observers_.push_back( observer );
674  return *this;
675  }
676 
683  {
684  on_enter_observers_.clear();
685  on_leave_observers_.clear();
686  return *this;
687  }
688 
698  self_type& add_begin_callback( std::function<void()> const& callback )
699  {
700  if( started_ ) {
701  throw std::runtime_error(
702  "Window Stream: Cannot change callbacks after iteration has started."
703  );
704  }
705  begin_callbacks_.push_back( callback );
706  return *this;
707  }
708 
716  self_type& add_end_callback( std::function<void()> const& callback )
717  {
718  if( started_ ) {
719  throw std::runtime_error(
720  "Window Stream: Cannot change callbacks after iteration has started."
721  );
722  }
723  end_callbacks_.push_back( callback );
724  return *this;
725  }
726 
732  {
733  if( started_ ) {
734  throw std::runtime_error(
735  "Window Stream: Cannot change callbacks after iteration has started."
736  );
737  }
738  begin_callbacks_.clear();
739  end_callbacks_.clear();
740  return *this;
741  }
742 
743  // -------------------------------------------------------------------------
744  // Iteration
745  // -------------------------------------------------------------------------
746 
748  {
749  if( started_ ) {
750  throw std::runtime_error(
751  "Window Stream is an input iterator (single pass), "
752  "but begin() has been called multiple times."
753  );
754  }
755  started_ = true;
756  return Iterator( this, get_begin_iterator_() );
757  }
758 
760  {
761  return Iterator( nullptr, get_end_iterator_() );
762  }
763 
764  // -------------------------------------------------------------------------
765  // Virtual Members
766  // -------------------------------------------------------------------------
767 
768 protected:
769 
770  // Need a default for WindowViewStream.
771  BaseWindowStream() = default;
772 
779  virtual std::unique_ptr<BaseIterator> get_begin_iterator_() = 0;
780 
787  virtual std::unique_ptr<BaseIterator> get_end_iterator_() = 0;
788 
789  // -------------------------------------------------------------------------
790  // Data Members
791  // -------------------------------------------------------------------------
792 
793 private:
794 
795  // Underlying iterator to the data that we want to put in windows.
796  InputStreamIterator begin_;
797  InputStreamIterator end_;
798  mutable bool started_ = false;
799 
800  // Keep the observers for each window view.
801  std::vector<std::function<void(WindowType const&)>> on_enter_observers_;
802  std::vector<std::function<void(WindowType const&)>> on_leave_observers_;
803 
804  // We furthermore allow callbacks for the beginning and and of the iteration.
805  std::vector<std::function<void()>> begin_callbacks_;
806  std::vector<std::function<void()>> end_callbacks_;
807 
808 };
809 
810 } // namespace population
811 } // namespace genesis
812 
813 #endif // include guard
genesis::population::BaseWindowStream::operator=
BaseWindowStream & operator=(BaseWindowStream const &)=default
genesis::population::BaseWindowStream::BaseIterator::Iterator
friend Iterator
Definition: base_window_stream.hpp:525
genesis::population::BaseWindowStream::Iterator::operator->
const value_type * operator->() const
Definition: base_window_stream.hpp:324
genesis::population::BaseWindowStream::Iterator::Iterator
Iterator(Iterator &&other)
Definition: base_window_stream.hpp:244
genesis::population::BaseWindowStream
Base class for streams of Windows over the chromosomes of a genome.
Definition: base_window_stream.hpp:119
genesis::population::BaseWindowStream::Iterator::~Iterator
~Iterator()=default
genesis::population::BaseWindowStream::BaseIterator::iterator_category
std::input_iterator_tag iterator_category
Definition: base_window_stream.hpp:491
genesis::population::BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type >::value_type
typename ::genesis::population::Window< typename InputStreamIterator::value_type > value_type
Definition: base_window_stream.hpp:134
genesis::population::BaseWindowStream::Iterator::operator->
value_type * operator->()
Definition: base_window_stream.hpp:330
genesis::population::BaseWindowStream::Iterator::pointer
value_type * pointer
Definition: base_window_stream.hpp:201
genesis::population::BaseWindowStream::BaseIterator::get_parent_
virtual BaseWindowStream const * get_parent_() const =0
Get a pointer to the base class parent.
genesis::population::BaseWindowStream::Iterator::const_reference
value_type const & const_reference
Definition: base_window_stream.hpp:203
genesis::population::BaseWindowStream::BaseIterator::get_current_window_
virtual value_type & get_current_window_() const =0
Get the current window that the iterator shall return when dereferenced.
genesis::population::BaseWindowStream::chromosome_function
std::function< std::string(InputType const &)> chromosome_function
Functor that yields the current chromosome, given the input stream data.
Definition: base_window_stream.hpp:152
genesis::population::BaseWindowStream::BaseIterator::is_last_window_
bool is_last_window_
Definition: base_window_stream.hpp:602
genesis::population::BaseWindowStream::BaseIterator::current_
InputStreamIterator current_
Definition: base_window_stream.hpp:605
genesis::population::BaseWindowStream::end
Iterator end()
Definition: base_window_stream.hpp:759
genesis::population::BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type >::InputStreamType
InputStreamIterator InputStreamType
Definition: base_window_stream.hpp:127
genesis::population::BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type >::const_reference
value_type const & const_reference
Definition: base_window_stream.hpp:137
genesis::population::BaseWindowStream::BaseIterator::end_
InputStreamIterator end_
Definition: base_window_stream.hpp:606
genesis::population::BaseWindowStream::Iterator::iterator_category
std::input_iterator_tag iterator_category
Definition: base_window_stream.hpp:199
genesis::population::BaseWindowStream::BaseIterator::value_type
WindowType value_type
Definition: base_window_stream.hpp:492
genesis::population::BaseWindowStream::BaseIterator::BaseIterator
BaseIterator(BaseWindowStream const *parent)
Construct the base class, which does initialization checks on its member variables to ensure that the...
Definition: base_window_stream.hpp:507
genesis::population::BaseWindowStream::Iterator::reference
value_type & reference
Definition: base_window_stream.hpp:202
std.hpp
Provides some valuable additions to STD.
genesis::population::BaseWindowStream::add_begin_callback
self_type & add_begin_callback(std::function< void()> const &callback)
Add a callback function that is executed when beginning the iteration.
Definition: base_window_stream.hpp:698
genesis::population::BaseWindowStream::BaseIterator::const_reference
value_type const & const_reference
Definition: base_window_stream.hpp:495
genesis::population::BaseWindowStream::clear_callbacks
self_type & clear_callbacks()
Clear all functions that have been added via add_begin_callback() and add_end_callback().
Definition: base_window_stream.hpp:731
genesis::population::BaseWindowStream::Iterator::operator!=
bool operator!=(self_type const &other) const
Definition: base_window_stream.hpp:394
genesis::population::BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type >::DataType
typename InputStreamIterator::value_type DataType
Definition: base_window_stream.hpp:128
genesis::population::BaseWindowStream::BaseIterator
Internal PIMPL-like implementation of the iterator that produces Windows.
Definition: base_window_stream.hpp:478
genesis::population::BaseWindowStream::Iterator
friend Iterator
Definition: base_window_stream.hpp:633
genesis::population::BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type >::reference
value_type & reference
Definition: base_window_stream.hpp:136
genesis::population::BaseWindowStream::BaseIterator::is_first_window_
bool is_first_window_
Definition: base_window_stream.hpp:601
genesis::population::BaseWindowStream::Iterator::is_first_window
bool is_first_window() const
Return whether the current iteration is the first of the current chromosome.
Definition: base_window_stream.hpp:286
genesis::population::BaseWindowStream::Iterator::Iterator
Iterator(BaseWindowStream const *parent, std::unique_ptr< BaseIterator > base_iterator)
Definition: base_window_stream.hpp:211
genesis::population::BaseWindowStream::add_on_enter_observer
self_type & add_on_enter_observer(std::function< void(WindowType const &)> const &observer)
Add a observer function that is executed once for each window during the iteration,...
Definition: base_window_stream.hpp:652
genesis::population::BaseWindowStream::Iterator
Internal public iterator that produces Windows.
Definition: base_window_stream.hpp:186
genesis::population::BaseWindowStream::~BaseWindowStream
virtual ~BaseWindowStream()=default
genesis::population::BaseWindowStream::Iterator::operator==
bool operator==(self_type const &other) const
Compare two iterators for equality.
Definition: base_window_stream.hpp:384
range.hpp
genesis::population::BaseWindowStream::position_function
std::function< size_t(InputType const &)> position_function
Functor that yields the current position on the chromosome, given the input stream data.
Definition: base_window_stream.hpp:158
genesis::population::BaseWindowStream::BaseWindowStream
BaseWindowStream(InputStreamIterator begin, InputStreamIterator end)
Definition: base_window_stream.hpp:620
genesis::population::BaseWindowStream::BaseIterator::BaseIterator
BaseIterator()=default
genesis::population::BaseWindowStream::BaseIterator::self_type
typename BaseWindowStream< InputStreamType, DataType, WindowType >::BaseIterator self_type
Definition: base_window_stream.hpp:488
genesis::population::BaseWindowStream::Iterator::operator*
const value_type & operator*() const
Definition: base_window_stream.hpp:312
genesis::population::BaseWindowStream::Iterator::Iterator
Iterator()=default
genesis::population::BaseWindowStream::Iterator::operator*
value_type & operator*()
Definition: base_window_stream.hpp:318
genesis
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Definition: placement/formats/edge_color.cpp:42
genesis::population::BaseWindowStream::add_end_callback
self_type & add_end_callback(std::function< void()> const &callback)
Add a callback function that is executed when the end of the iteration is reached.
Definition: base_window_stream.hpp:716
genesis::population::BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type >::pointer
value_type * pointer
Definition: base_window_stream.hpp:135
genesis::population::BaseWindowStream::begin
Iterator begin()
Definition: base_window_stream.hpp:747
genesis::population::BaseWindowStream::Iterator::self_type
typename BaseWindowStream< InputStreamType, DataType, WindowType >::Iterator self_type
Definition: base_window_stream.hpp:196
genesis::population::BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type >::iterator_category
std::input_iterator_tag iterator_category
Definition: base_window_stream.hpp:133
window.hpp
genesis::population::BaseWindowStream::entry_input_function
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...
Definition: base_window_stream.hpp:147
genesis::population::BaseWindowStream::BaseIterator::pointer
value_type * pointer
Definition: base_window_stream.hpp:493
genesis::population::BaseWindowStream::Iterator::operator++
self_type & operator++()
Definition: base_window_stream.hpp:340
genesis::population::BaseWindowStream::BaseIterator::init_
void init_(BaseWindowStream const *parent)
Initialize the base iterator class and check that it is set up correctly.
Definition: base_window_stream.hpp:536
genesis::population::BaseWindowStream::Iterator::value_type
WindowType value_type
Definition: base_window_stream.hpp:200
genesis::population::BaseWindowStream::Iterator::BaseWindowStream
friend BaseWindowStream
Definition: base_window_stream.hpp:270
genesis::population::BaseWindowStream::Iterator::is_last_window
bool is_last_window() const
Return whether the current iteration is the last of the current chromosome.
Definition: base_window_stream.hpp:302
genesis::population::BaseWindowStream::BaseIterator::increment_
virtual void increment_()=0
Advance in the iteration. This function is called from operator++.
genesis::population::BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type >::InputType
typename InputStreamIterator::value_type InputType
Definition: base_window_stream.hpp:131
genesis::population::BaseWindowStream::BaseIterator::reference
value_type & reference
Definition: base_window_stream.hpp:494
genesis::population::BaseWindowStream::add_on_leave_observer
self_type & add_on_leave_observer(std::function< void(WindowType const &)> const &observer)
Add a observer function that is executed once for each window during the iteration,...
Definition: base_window_stream.hpp:671
genesis::population::BaseWindowStream::Iterator::InputType
typename InputStreamType::value_type InputType
Definition: base_window_stream.hpp:197
genesis::population::BaseWindowStream::Iterator::operator=
Iterator & operator=(Iterator const &)=delete
genesis::population::BaseWindowStream::BaseWindowStream
BaseWindowStream()=default
genesis::population::BaseWindowStream::BaseIterator::BaseWindowStream
friend BaseWindowStream
Definition: base_window_stream.hpp:524
genesis::population::BaseWindowStream::get_begin_iterator_
virtual std::unique_ptr< BaseIterator > get_begin_iterator_()=0
Get the begin iterator.
genesis::population::BaseWindowStream::BaseIterator::InputType
typename InputStreamType::value_type InputType
Definition: base_window_stream.hpp:489
genesis::population::BaseWindowStream::BaseIterator::~BaseIterator
virtual ~BaseIterator()=default
genesis::population::BaseWindowStream::get_end_iterator_
virtual std::unique_ptr< BaseIterator > get_end_iterator_()=0
Get the end iterator.
genesis::population::BaseWindowStream::clear_observers
self_type & clear_observers()
Clear all functions that are executed on incrementing to the next element.
Definition: base_window_stream.hpp:682