51 #ifndef LIB_ITER_SOURCE_H 52 #define LIB_ITER_SOURCE_H 60 #include <type_traits> 122 operator string() const
124 return "IterSource<" + lib::meta::typeStr<TY>()+
">";
131 checkPoint (DataHandle
const&, Pos
const& pos)
137 iterNext (DataHandle& source, Pos& pos)
140 source->nextResult(pos);
150 using _I::IterAdapter;
163 startIteration (DataHandle{&sourceImpl, &detach_without_destroy}));
176 startIteration (DataHandle{sourceImplObject, &destroy_managed_source}));
181 using value_type = TY;
182 using reference = TY&;
189 startIteration (DataHandle sourceHandle)
191 REQUIRE (sourceHandle);
192 Pos first = sourceHandle->firstResult();
193 return {move(sourceHandle), first};
200 WARN_IF (!source, library,
"IterSource deleter called with NULL source pointer");
208 WARN_IF (!source, library,
"IterSource deleter called with NULL source pointer");
219 template<
typename TY>
232 template<class IT, class ISO = IterSource<typename meta::ValueTypeBinding<IT>::value_type>>
240 using Pos =
typename ISO::Pos;
270 : src_(forward<IT>(orig))
275 IT& wrappedIter() {
return src_; }
276 IT
const& wrappedIter()
const {
return src_; }
284 namespace iter_source {
290 using Val =
typename CON::iterator::value_type;
297 using Val =
typename IT::value_type;
304 using Key =
typename MAP::key_type;
305 using Val =
typename MAP::value_type::second_type;
314 using Src =
typename std::remove_reference<IT>::type;
315 using Val =
typename Src::value_type;
319 template<
class IT,
class FUN>
322 using Src =
typename std::remove_reference<IT>::type;
331 using Src =
typename std::remove_reference<IT>::type;
332 using PairType =
typename Src::value_type;
333 using ValType =
typename PairType::second_type;
334 using ConstKeyType =
typename PairType::first_type;
338 using KeyType =
typename std::remove_const<ConstKeyType>::type;
343 static KeyType takeFirst (PairType
const& pair) {
return pair.first; }
344 static ValType takeSecond(PairType
const& pair) {
return pair.second;}
350 takePairFirst (IT&&
source)
357 takePairSecond (IT&&
source)
370 typename _IterT<IT>::Iter
373 using Src =
typename _IterT<IT>::Src;
374 using Val =
typename _IterT<IT>::Val;
385 template<
typename VAL>
390 using Val =
typename _IterT<Src>::Val;
405 template<
class IT,
class FUN>
406 typename _TransformIterT<IT,FUN>::Iter
409 typedef typename _TransformIterT<IT,FUN>::ResVal ValType;
410 typedef typename _TransformIterT<IT,FUN>::TransIter TransIT;
422 typename _MapT<MAP>::KeyIter
427 Range
contents (map.begin(), map.end());
436 typename _MapT<MAP>::ValIter
441 Range
contents (map.begin(), map.end());
452 typename _MapT<MAP>::KeyIter
453 eachDistinctKey (MAP& map)
457 Range
contents (map.begin(), map.end());
467 typename _MapT<MAP>::ValIter
468 eachValForKey (MAP& map,
typename _MapT<MAP>::Key key)
470 using Pos =
typename MAP::iterator;
473 std::pair<Pos,Pos> valuesForKey = map.equal_range(key);
474 Range
contents (valuesForKey.first, valuesForKey.second);
475 return wrapIter (takePairSecond(contents));
486 typename _SeqT<CON>::Iter
489 using ValType =
typename _SeqT<CON>::Val;
492 Range
contents (container.begin(), container.end());
501 typename _RangeT<IT>::Iter
504 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...