Lumiera  0.pre.03
»edit your freedom«
iter-source.hpp File Reference

Go to the source code of this file.

Description

Extension module to build an opaque data source, accessible as Lumiera Forward Iterator.

It is based on combining an IterAdapter with classical polymorphism; here, the data source, which is addressed by IderAdapter through the "iteration control API", is abstracted behind an interface (with virtual functions). Together this allows to build a simple data source type, without needing to disclose details of the implementation.

Todo:
the design used for the "iteration control API" is misaligned with the purpose of this adapter. Rather, it should be shaped similar to IterStateWrapper with three control functions //////////////////////////////////////TICKET #1125

Standard Adapters

As a complement, this header contains a generic implementation of the IterSource interface by wrapping an existing Lumiera Forward Iterator. Using this WrappedLumieraIter, the details of this wrapped source iterator remain opaque. To ease the use of this adapter, a selection of free functions is provided, allowing to build opaque "all elements" or "all keys" iterators for various STL containers.

See also
iter-adapter.hpp
itertool.hpp
iter-source-test.cpp

Definition in file iter-source.hpp.

#include "lib/meta/util.hpp"
#include "lib/iter-adapter.hpp"
#include "lib/itertools.hpp"
#include "lib/nocopy.hpp"
#include <type_traits>
#include <utility>
#include <string>
#include <memory>

Classes

struct  _IterT< IT >
 
struct  _MapT< MAP >
 
struct  _PairIterT< IT >
 
struct  _RangeT< IT >
 
struct  _SeqT< CON >
 
struct  _TransformIterT< IT, FUN >
 
struct  IterSource< TY >::iterator
 
class  IterSource< TY >
 Iteration source interface to abstract a data source, which then can be accessed through IterAdapter as a frontend, allowing to pull individual elements until exhaustion. More...
 
class  WrappedLumieraIter< IT, ISO >
 Standard implementation of the IterSource interface: a wrapped "Lumiera Forward Iterator". More...
 

Functions

template<class MAP >
_MapT< MAP >::KeyIter eachDistinctKey (MAP &map)
 
template<class CON >
_SeqT< CON >::Iter eachEntry (CON &container)
 
template<class IT >
_RangeT< IT >::Iter eachEntry (IT const &begin, IT const &end)
 
template<class MAP >
_MapT< MAP >::KeyIter eachMapKey (MAP &map)
 
template<class MAP >
_MapT< MAP >::ValIter eachMapVal (MAP &map)
 
template<class MAP >
_MapT< MAP >::ValIter eachValForKey (MAP &map, typename _MapT< MAP >::Key key)
 
template<typename VAL >
auto singleVal (VAL &&something)
 an IterSource frontend to return just a single value once. More...
 
template<class IT >
_PairIterT< IT >::KeyIter takePairFirst (IT &&source)
 
template<class IT >
_PairIterT< IT >::ValIter takePairSecond (IT &&source)
 
template<class IT , class FUN >
_TransformIterT< IT, FUN >::Iter transform (IT &&source, FUN processingFunc)
 pipes a given Lumiera Forward Iterator through a transformation function and wraps the resulting transforming Iterator, exposing just an IterSource. More...
 
template<class IT >
_IterT< IT >::Iter wrapIter (IT &&source)
 wraps a given Lumiera Forward Iterator, exposing just a IterSource based frontend.
 

Namespaces

 lib
 Implementation namespace for support and library code.
 

Class Documentation

◆ lib::iter_source::anonymous_namespace{iter-source.hpp}::_IterT

struct lib::iter_source::anonymous_namespace{iter-source.hpp}::_IterT
Class Members
typedef typename
remove_reference< IT >::type
Src
typedef typename value_type Val
typedef typename IterSource
< Val >::iterator
Iter
+ Collaboration diagram for _IterT< IT >:

◆ lib::iter_source::anonymous_namespace{iter-source.hpp}::_MapT

struct lib::iter_source::anonymous_namespace{iter-source.hpp}::_MapT
Class Members
typedef typename key_type Key
typedef typename second_type Val
typedef typename IterSource
< Key >::iterator
KeyIter
typedef typename IterSource
< Val >::iterator
ValIter
+ Collaboration diagram for _MapT< MAP >:

◆ lib::iter_source::anonymous_namespace{iter-source.hpp}::_RangeT

struct lib::iter_source::anonymous_namespace{iter-source.hpp}::_RangeT
Class Members
typedef typename value_type Val
typedef typename IterSource
< Val >::iterator
Iter
+ Collaboration diagram for _RangeT< IT >:

◆ lib::iter_source::anonymous_namespace{iter-source.hpp}::_SeqT

struct lib::iter_source::anonymous_namespace{iter-source.hpp}::_SeqT
Class Members
typedef typename value_type Val
typedef typename IterSource
< Val >::iterator
Iter
+ Collaboration diagram for _SeqT< CON >:

◆ lib::iter_source::anonymous_namespace{iter-source.hpp}::_TransformIterT

struct lib::iter_source::anonymous_namespace{iter-source.hpp}::_TransformIterT
Class Members
typedef typename
remove_reference< IT >::type
Src
typedef typename _Fun< FUN >::Ret ResVal
typedef TransformIter< Src,
ResVal >
TransIter
typedef typename IterSource
< ResVal >::iterator
Iter
+ Collaboration diagram for _TransformIterT< IT, FUN >:

Function Documentation

◆ singleVal()

auto lib::iter_source::singleVal ( VAL &&  something)

an IterSource frontend to return just a single value once.

Warning
behind the scenes, a heap allocation is managed by shared_ptr, to maintain a copy of the wrapped element. When passing a reference, only a reference will be wrapped, but a heap allocation happens nonetheless

Definition at line 387 of file iter-source.hpp.

References IterSource< TY >::build(), lib::iter_source::singleVal(), and lib::singleValIterator().

Referenced by lib::iter_source::singleVal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transform()

_TransformIterT<IT,FUN>::Iter lib::iter_source::transform ( IT &&  source,
FUN  processingFunc 
)

pipes a given Lumiera Forward Iterator through a transformation function and wraps the resulting transforming Iterator, exposing just an IterSource.

This convenience shortcut can be used to build a processing chain; the resulting IterSource will hide any detail types involved.

Note
as with any IterSource, there is one virtual function call for every fetched element.

Definition at line 407 of file iter-source.hpp.

References IterSource< TY >::build(), IterAdapter< Pos, DataHandle >::source(), lib::iter_source::transform(), and lib::transformIterator().

Referenced by lib::iter_source::transform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eachMapKey()

_MapT<MAP>::KeyIter lib::iter_source::eachMapKey ( MAP &  map)
Returns
a Lumiera Forward Iterator to yield all the keys of the given Map or Hashtable

Definition at line 423 of file iter-source.hpp.

References lib::diff::test::anonymous_namespace{diff-tree-application-simple-test.cpp}::contents(), lib::iter_source::eachMapKey(), and lib::iter_source::wrapIter().

Referenced by lib::iter_source::eachMapKey().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eachMapVal()

_MapT<MAP>::ValIter lib::iter_source::eachMapVal ( MAP &  map)
Returns
a Lumiera Forward Iterator to yield all the values of the given Map or Hashtable

Definition at line 437 of file iter-source.hpp.

References lib::diff::test::anonymous_namespace{diff-tree-application-simple-test.cpp}::contents(), lib::iter_source::eachMapVal(), and lib::iter_source::wrapIter().

Referenced by lib::iter_source::eachMapVal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eachDistinctKey()

_MapT<MAP>::KeyIter lib::iter_source::eachDistinctKey ( MAP &  map)
Returns
a Lumiera Forward Iterator to yield all distinct keys of a Multimap
Warning
we do a full table scan to find the distinct keys

Definition at line 453 of file iter-source.hpp.

References lib::diff::test::anonymous_namespace{diff-tree-application-simple-test.cpp}::contents(), lib::filterRepetitions(), and lib::iter_source::wrapIter().

+ Here is the call graph for this function:

◆ eachValForKey()

_MapT<MAP>::ValIter lib::iter_source::eachValForKey ( MAP &  map,
typename _MapT< MAP >::Key  key 
)
Returns
a Lumiera Forward Iterator to yield all values associated to the given key within this Map or Multimap
Note
obviously in case of a Map we'll get at most one result.

Definition at line 468 of file iter-source.hpp.

◆ eachEntry() [1/2]

_SeqT<CON>::Iter lib::iter_source::eachEntry ( CON &  container)
Parameters
containera STL-like container, providing
  • a typedef iterator
  • functions begin() and end()
Returns
a Lumiera Forward Iterator yielding all values starting with begin and excluding end .

Definition at line 487 of file iter-source.hpp.

References IterSource< TY >::build(), lib::diff::test::anonymous_namespace{diff-tree-application-simple-test.cpp}::contents(), and lib::iter_source::eachEntry().

Referenced by lib::iter_source::eachEntry().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eachEntry() [2/2]

_RangeT<IT>::Iter lib::iter_source::eachEntry ( IT const &  begin,
IT const &  end 
)
Returns
a Lumiera Forward Iterator to yield all values defined by a classical Iterator range.

Definition at line 502 of file iter-source.hpp.

References IterSource< TY >::build(), lib::diff::test::anonymous_namespace{diff-tree-application-simple-test.cpp}::contents(), and lib::iter_source::eachEntry().

+ Here is the call graph for this function: