Lumiera  0.pre.03
»edit your freedom«
iter-explorer-test.cpp File Reference

Go to the source code of this file.

Description

The IterExplorer_test covers and demonstrates a generic mechanism to expand and evaluate tree like structures.

It was created in response to a recurring need for configurable tree expanding and backtracking evaluations. Due to the nature of Lumiera's design, we repeatedly encounter this kind of algorithms, when it comes to matching configuration and parametrisation against a likewise hierarchical and rules based model. To keep the code base maintainable, we deem it crucial to reduce the inherent complexity in such algorithms by clearly separate the mechanics of evaluation from the actual logic of the target domain.

This test relies on a demonstration setup featuring a custom encapsulated state type: we rely on a counter with start and end value, embedded into an iterator as »state core«. This running counter, when iterated, generates a descending sequence of numbers start ... end. So – conceptually – this counting iterator can be conceived as representing this sequence of numbers, while not actually representing all these numbers as data in memory. And this is the whole point of the exercise: not to represent this sequence in runtime state at once, rather to __pull and expand it on demand._

All these tests work by first defining these functional structures, which just yields an iterator entity. We get the whole structure it conceptually defines only if we »pull« and »materialise« this iterator until exhaustion — which essentially is what the test does to verify proper operation. In contrast, Real World Code of course would not proceed in this way, like pulling everything from such an iterator. Since often the very reason we're using such a setup is the ability to represent infinite structures. Like e.g. the evaluation graph of video passed through a complex processing pipeline.

Definition in file iter-explorer-test.cpp.

#include "lib/test/run.hpp"
#include "lib/test/test-helper.hpp"
#include "lib/iter-adapter-stl.hpp"
#include "lib/format-string.hpp"
#include "lib/format-cout.hpp"
#include "lib/format-util.hpp"
#include "lib/itertools.hpp"
#include "lib/util.hpp"
#include "lib/iter-explorer.hpp"
#include "lib/meta/trait.hpp"
#include <utility>
#include <vector>
#include <limits>
#include <string>
#include <tuple>
#include <cmath>

Classes

struct  CountDown
 This iteration _"state core" type_ describes a descending sequence of numbers yet to be delivered. More...
 
class  IterExplorer_test
 
struct  IterExplorer_test::MagicTestRubbish< SRC >
 demo of a custom processing layer interacting directly with the iteration mechanism. More...
 
class  NumberSequence
 A straight descending number sequence as basic test iterator. More...
 
class  RandomSeq
 Another iteration _"state core"_ to produce a sequence of random numbers. More...
 

Functions

 LAUNCHER (IterExplorer_test, "unit common")
 
template<class II >
string materialise (II &&ii)
 Diagnostic helper: join all the elements from a copy of the iterator.
 
template<class II >
void pullOut (II &ii)
 Diagnostic helper: "squeeze out" the given iterator until exhaustion.
 

Namespaces

 lib
 Implementation namespace for support and library code.