42 #ifndef LIB_ITER_SOURCE_H 43 #define LIB_ITER_SOURCE_H 51 #include <type_traits> 113 operator string() const
115 return "IterSource<" + lib::meta::typeStr<TY>()+
">";
122 checkPoint (DataHandle
const&, Pos
const& pos)
128 iterNext (DataHandle& source, Pos& pos)
131 source->nextResult(pos);
141 using _I::IterAdapter;
154 startIteration (DataHandle{&sourceImpl, &detach_without_destroy}));
167 startIteration (DataHandle{sourceImplObject, &destroy_managed_source}));
172 using value_type = TY;
173 using reference = TY&;
180 startIteration (DataHandle sourceHandle)
182 REQUIRE (sourceHandle);
183 Pos first = sourceHandle->firstResult();
184 return {move(sourceHandle), first};
191 WARN_IF (!source, library,
"IterSource deleter called with NULL source pointer");
199 WARN_IF (!source, library,
"IterSource deleter called with NULL source pointer");
210 template<
typename TY>
223 template<class IT, class ISO = IterSource<typename meta::ValueTypeBinding<IT>::value_type>>
231 using Pos =
typename ISO::Pos;
261 : src_(forward<IT>(orig))
266 IT& wrappedIter() {
return src_; }
267 IT
const& wrappedIter()
const {
return src_; }
275 namespace iter_source {
281 using Val =
typename CON::iterator::value_type;
288 using Val =
typename IT::value_type;
295 using Key =
typename MAP::key_type;
296 using Val =
typename MAP::value_type::second_type;
305 using Src =
typename std::remove_reference<IT>::type;
306 using Val =
typename Src::value_type;
310 template<
class IT,
class FUN>
313 using Src =
typename std::remove_reference<IT>::type;
322 using Src =
typename std::remove_reference<IT>::type;
323 using PairType =
typename Src::value_type;
324 using ValType =
typename PairType::second_type;
325 using ConstKeyType =
typename PairType::first_type;
329 using KeyType =
typename std::remove_const<ConstKeyType>::type;
334 static KeyType takeFirst (PairType
const& pair) {
return pair.first; }
335 static ValType takeSecond(PairType
const& pair) {
return pair.second;}
341 takePairFirst (IT&&
source)
348 takePairSecond (IT&&
source)
361 typename _IterT<IT>::Iter
364 using Src =
typename _IterT<IT>::Src;
365 using Val =
typename _IterT<IT>::Val;
376 template<
typename VAL>
381 using Val =
typename _IterT<Src>::Val;
396 template<
class IT,
class FUN>
397 typename _TransformIterT<IT,FUN>::Iter
400 typedef typename _TransformIterT<IT,FUN>::ResVal ValType;
401 typedef typename _TransformIterT<IT,FUN>::TransIter TransIT;
413 typename _MapT<MAP>::KeyIter
418 Range
contents (map.begin(), map.end());
427 typename _MapT<MAP>::ValIter
432 Range
contents (map.begin(), map.end());
443 typename _MapT<MAP>::KeyIter
444 eachDistinctKey (MAP& map)
448 Range
contents (map.begin(), map.end());
458 typename _MapT<MAP>::ValIter
459 eachValForKey (MAP& map,
typename _MapT<MAP>::Key key)
461 using Pos =
typename MAP::iterator;
464 std::pair<Pos,Pos> valuesForKey = map.equal_range(key);
465 Range
contents (valuesForKey.first, valuesForKey.second);
466 return wrapIter (takePairSecond(contents));
477 typename _SeqT<CON>::Iter
480 using ValType =
typename _SeqT<CON>::Val;
483 Range
contents (container.begin(), container.end());
492 typename _RangeT<IT>::Iter
495 using ValType =
typename _RangeT<IT>::Val;
_IterT< IT >::Iter wrapIter(IT &&source)
wraps a given Lumiera Forward Iterator, exposing just a IterSource based frontend.
static iterator EMPTY_SOURCE
storage for the empty data-source constant
Helper template(s) for creating Lumiera Forward Iterators.
Any copy and copy construction prohibited.
ConRef source()
allow derived classes to access backing container
Implementation namespace for support and library code.
virtual void nextResult(Pos &pos)=0
iteration step: switch on to the next element.
Iteration source interface to abstract a data source, which then can be accessed through IterAdapter ...
Mix-Ins to allow or prohibit various degrees of copying and cloning.
auto singleVal(VAL &&something)
an IterSource frontend to return just a single value once.
_MapT< MAP >::KeyIter eachMapKey(MAP &map)
_TransformIterT< IT, FUN >::Iter transform(IT &&source, FUN processingFunc)
pipes a given Lumiera Forward Iterator through a transformation function and wraps the resulting tran...
auto singleValIterator(VAL &&something)
Build a SingleValIter: convenience free function shortcut, to pick up just any value and wrap it as L...
_MapT< MAP >::ValIter eachMapVal(MAP &map)
static iterator build(IterSource &sourceImpl)
build an iterator frontend for the given source,
virtual Pos firstResult()=0
iteration start: prepare the first element.
Accessing a STL element range through a Lumiera forward iterator, An instance of this iterator adapte...
auto transformIterator(IT const &src, FUN processingFunc)
Build a TransformIter: convenience free function shortcut, picking up the involved types automaticall...
Standard implementation of the IterSource interface: a wrapped "Lumiera Forward Iterator".
string contents(Rec const &object)
render the child elements as string data for test/verification
Adapter for building an implementation of the »Lumiera Forward Iterator« concept. ...
virtual void disconnect()
disconnect the data source / iteration frontend.
_SeqT< CON >::Iter eachEntry(CON &container)
auto filterRepetitions(IT const &source)
filters away repeated values emitted by source iterator
static iterator build(IterSource *sourceImplObject)
build an iterator frontend, thereby managing the given heap allocated source object instance...