TreeExplorer: draft my requirements for packaging a TreeExplorer pipeline as IterSource

Since this now requires to import iter-adapter-stl.hpp and iter-source.hpp
at the same time, I decided to drop the convenience imports of the STL adapters
into namespace lib. There is no reason to prefer the IterSource-based adapters
over the iter-adapter-stl.hpp variants of the same functionality.
Thus better always import them explicitly at usage site.


...actual implementation of the planned IterSource packaging is only stubbed.
But I needed to redeclare a lot of ctors, which doesn't seem logical
And I get a bad function invocation from another test case which worked correct beforehand.
This commit is contained in:
Fischlurch 2017-12-07 05:48:36 +01:00
parent 9b9dcb2b78
commit aa008d6d4a
14 changed files with 191 additions and 32 deletions

View file

@ -183,8 +183,8 @@ namespace interact {
{
return Symbol{id};
};
return depth==UIC_PERSP? lib::singleVal (internedString (node.getType()))
: lib::transform (node.keys(), internedString);
return depth==UIC_PERSP? lib::iter_source::singleVal (internedString (node.getType()))
: lib::iter_source::transform (node.keys(), internedString);
/////////////////////////////////////////////////////////////////////TICKET #1113 : could just use lib::wrapIter when GenNode exposes Literal as ID
}

View file

@ -36,7 +36,7 @@
//#include "include/interfaceproxy.hpp"
#include "lib/handle.hpp"
#include "lib/iter-source.hpp"
#include "lib/iter-source.hpp" ////////////////////TICKET #493 : only using the IterSource base interface here
#include "lib/time/control.hpp"
#include "lib/time/timevalue.hpp"
#include "include/interfaceproxy.hpp"

View file

@ -142,9 +142,16 @@ namespace lib {
struct iterator
: IterAdapter<Pos, DataHandle>
{
using _I = IterAdapter<Pos, DataHandle>
;
using _I = IterAdapter<Pos, DataHandle>;
using _I::IterAdapter;
iterator() =default; /////////////////////////////////////TICKET #1117 : why the hell do we need to declare all those ctor variants explicitly? I was under the impression ctor calls worked correct up to now without all this...
iterator(iterator&&) =default;
iterator(iterator const&) =default;
iterator(iterator& r) : iterator((iterator const&)r) { }
iterator& operator= (iterator &&) =default;
iterator& operator= (iterator const&) =default;
operator string() const {return _I::source()? string(*_I::source()) : ""; }
};
@ -494,16 +501,7 @@ namespace lib {
Range contents (begin, end);
return IterSource<ValType>::build (new WrappedLumieraIter<Range>(contents));
}
}
using iter_source::wrapIter;
using iter_source::singleVal;
using iter_source::transform;
using iter_source::eachMapKey;
using iter_source::eachDistinctKey;
using iter_source::eachValForKey;
using iter_source::eachMapVal;
using iter_source::eachEntry;
} // namespace lib
}} // namespace lib::iter_source
#endif

View file

@ -95,6 +95,7 @@
#include "lib/meta/trait.hpp"
#include "lib/wrapper.hpp" ////////////TODO : could be more lightweight by splitting FunctionResult into separate header. Relevant?
#include "lib/iter-adapter.hpp"
#include "lib/iter-source.hpp" /////////////TICKET #493 : only using the IterSource base feature / interface here. Should really split the iter-source.hpp
#include "lib/iter-stack.hpp"
#include "lib/util.hpp"
#include "lib/test/test-helper.hpp"///////////TODO Bug-o
@ -452,6 +453,10 @@ namespace lib {
: SRC
{
using SRC::SRC;
BaseAdapter(SRC const& src) : SRC(src) { } ////////////////////////TODO why the hell do we need to redeclare all those ctor variants????
BaseAdapter(SRC && src) : SRC(src) { }
BaseAdapter(SRC & src) : SRC(src) { }
BaseAdapter() = default;
void expandChildren() { }
};
@ -732,6 +737,25 @@ namespace lib {
/**
* @todo WIP 12/2017
*/
template<typename VAL>
struct IterExploreSource
: IterSource<VAL>::iterator
{
//////TODO clarify allowed ctors
void
expandChildren()
{
UNIMPLEMENTED ("how to phone home...");
}
private:
};
/**
* Adapter to build a demand-driven tree expanding and exploring computation
* based on a custom opaque _state core_. TreeExploer adheres to the _Monad_
@ -757,6 +781,10 @@ namespace lib {
/** pass-through ctor */
using SRC::SRC;
TreeExplorer(SRC const& src) : SRC(src) { } ////////////////////////TODO why the hell do we need to redeclare all those ctor variants???? why isn't copy initialisation propagated from the base ctors?
TreeExplorer(SRC && src) : SRC(src) { }
TreeExplorer(SRC & src) : SRC(src) { }
TreeExplorer() = default;
@ -842,6 +870,15 @@ namespace lib {
}
/** @todo package as IterSource
*/
IterExploreSource<value_type>
asIterSource()
{
UNIMPLEMENTED ("wrap into IterSource");
}
private:
};
@ -866,7 +903,7 @@ namespace lib {
using SrcIter = typename _DecoratorTraits<IT>::SrcIter;
using Base = iter_explorer::BaseAdapter<SrcIter>;
return TreeExplorer<Base> {std::forward<IT>(srcSeq)};
return TreeExplorer<Base> (std::forward<IT> (srcSeq));
}

View file

@ -43,7 +43,7 @@ namespace engine{
using std::function;
using std::bind;
using std::ref;
using lib::transform;
using lib::iter_source::transform;
using lib::append_all;

View file

@ -79,6 +79,9 @@ namespace session {
using lib::TypedAllocationManager;
using lib::iter_stl::IterSnapshot;
using lib::iter_stl::eachVal;
using lib::iter_source::eachMapKey;
using lib::iter_source::eachDistinctKey;
using lib::iter_source::eachValForKey;
using std::placeholders::_1;
using std::function;
using std::bind;

View file

@ -43,7 +43,7 @@
#include "proc/mobject/session/query-focus-stack.hpp"
#include "proc/mobject/session/session-service-explore-scope.hpp"
#include "proc/mobject/mobject.hpp"
#include "lib/iter-source.hpp" ////////////////////TICKET #493 : using the IterSource adapters here
#include "lib/iter-source.hpp" ////////////////////TICKET #493 : only using the IterSource wrapIter adapter here
#include "common/query/query-resolver.hpp"
#include <vector>

View file

@ -131,7 +131,6 @@ namespace play {
using lumiera::Query;
// using lib::ScopedCollection;
// using lib::Literal;
using lib::eachEntry;
typedef asset::ID<Pipe> PID;
typedef asset::ID<Struct> TID;
@ -207,7 +206,7 @@ namespace play {
ModelPorts
getAllModelPorts()
{
return eachEntry (modelPorts_.begin(), modelPorts_.end());
return lib::iter_source::eachEntry (modelPorts_.begin(), modelPorts_.end());
}
};
}

View file

@ -64,7 +64,6 @@ namespace play {
//using proc::engine::BufferProvider;
//using lib::time::Time;
//using std::string;
using lib::transform;
using lib::iter_stl::eachElm;
//using std::placeholders::_1;
@ -177,7 +176,7 @@ namespace play {
{
//////////////////////////TICKET #878 not re-entrant, lifecycle isn't clear
REQUIRE (this->isActive());
return transform (eachElm(connections_), connectOutputSink);
return lib::iter_source::transform (eachElm(connections_), connectOutputSink);
}
Timings

View file

@ -35,6 +35,8 @@
//#include <memory>
//#include <functional>
using lib::iter_source::transform;
using lib::append_all;
namespace proc {
@ -43,8 +45,6 @@ namespace play {
// using std::string;
// using lumiera::Subsys;
// using std::bind;
using lib::transform;
using lib::append_all;
namespace { // Implementation details...

View file

@ -58,7 +58,7 @@
//#include "lib/singleton-ref.hpp"
#include "proc/mobject/model-port.hpp"
#include "proc/engine/calc-stream.hpp"
#include "lib/iter-source.hpp"
#include "lib/iter-source.hpp" ////////////////////TICKET #493 : only using the IterSource base feature here
#include "lib/util.hpp"
//
#include <boost/noncopyable.hpp>

View file

@ -61,6 +61,14 @@ namespace test{
using lumiera::error::LUMIERA_ERROR_ITER_EXHAUST;
using iter_source::eachEntry;
using iter_source::transform;
using iter_source::singleVal;
using iter_source::eachMapKey;
using iter_source::eachMapVal;
using iter_source::eachValForKey;
using iter_source::eachDistinctKey;
namespace { // Subject of test

View file

@ -723,12 +723,42 @@ namespace test{
/** @test package the resulting Iterator as automatically managed,
* polymorphic opaque implementing the IterSource interface.
* polymorphic opaque entity implementing the IterSource interface.
*/
void
verify_asIterSource()
{
UNIMPLEMENTED("package as IterSource");
IterSource<uint>::iterator sequence;
CHECK (isnil (sequence));
sequence = treeExplore(CountDown{20,10})
.filter([](uint i){ return i % 2; })
.asIterSource();
CHECK (not isnil (sequence));
CHECK (19 == *sequence);
cout << materialise (sequence) <<endl;
sequence = treeExplore(sequence)
.transform([](uint i){ return i*2; })
.asIterSource();
CHECK (38 == *sequence);
IterExploreSource<char> exploreIter;
CHECK (isnil (exploreIter));
exploreIter = treeExplore(sequence)
.filter([](int i){ return i>30; })
.expand([](int i){ return CountDown{i-10, 20}; })
.transform([](uint u) -> char { return '@'+u-20; })
.asIterSource();
CHECK (38 == *sequence);
cout << materialise(exploreIter) << endl;
CHECK (isnil (sequence));
}

View file

@ -5691,7 +5691,7 @@
</node>
</node>
</node>
<node COLOR="#338800" CREATED="1511837279715" ID="ID_1694539348" MODIFIED="1512612114861" TEXT="filter-Operation">
<node COLOR="#338800" CREATED="1511837279715" FOLDED="true" ID="ID_1694539348" MODIFIED="1512621166351" TEXT="filter-Operation">
<icon BUILTIN="button_ok"/>
<node CREATED="1511837285306" ID="ID_928417859" MODIFIED="1511837293629" TEXT="der Vollst&#xe4;ndigkeit halber">
<node CREATED="1511837296921" ID="ID_151298846" MODIFIED="1511837304547" TEXT="ist zwar redundant zu den Itertools"/>
@ -6018,12 +6018,39 @@
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1511837384749" ID="ID_274979743" MODIFIED="1511837465023" TEXT="asIterSource">
<icon BUILTIN="hourglass"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1511837384749" ID="ID_274979743" MODIFIED="1512621181803" TEXT="asIterSource">
<icon BUILTIN="pencil"/>
<node CREATED="1512621242778" ID="ID_695969017" MODIFIED="1512621248235" TEXT="Eigenschaften">
<icon BUILTIN="info"/>
<node CREATED="1511837396075" ID="ID_1916743569" MODIFIED="1511837401078" TEXT="abschlie&#xdf;ender Dekorator"/>
<node CREATED="1511837401738" ID="ID_289320579" MODIFIED="1511837414204" TEXT="verpackt hinter OO-Interface mit virtuellen Funktionen"/>
<node CREATED="1511837421967" ID="ID_906113750" MODIFIED="1511837433914" TEXT="automatische Heap-Storage"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1512621260992" ID="ID_611871784" MODIFIED="1512621309522" TEXT="erweitertes Interface">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1512621268527" ID="ID_1388034155" MODIFIED="1512621305821" TEXT="wie bauen?">
<icon BUILTIN="help"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1512621274166" ID="ID_1452751365" MODIFIED="1512621301316" TEXT="wie expand() an die Quelle weitergeben?">
<icon BUILTIN="help"/>
</node>
</node>
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1512621185490" ID="ID_1611878074" MODIFIED="1512621201039" TEXT="Probleme">
<icon BUILTIN="messagebox_warning"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1512621202688" ID="ID_57740660" MODIFIED="1512621221197" TEXT="durchreichen der Basis-Konstruktoren">
<icon BUILTIN="flag-yellow"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1512621222901" ID="ID_701320194" MODIFIED="1512621233228" TEXT="bad function call">
<icon BUILTIN="flag-yellow"/>
<node CREATED="1512621654283" ID="ID_1975194377" MODIFIED="1512621667489" TEXT="passiert im FIlter-Iterator-Test">
<icon BUILTIN="messagebox_warning"/>
</node>
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1512621668449" ID="ID_369576813" MODIFIED="1512621682544" TEXT="hab ich einen schon funktionierenden Test gebrochen?">
<icon BUILTIN="flag-pink"/>
</node>
</node>
</node>
</node>
<node CREATED="1512358595283" FOLDED="true" ID="ID_1526405052" MODIFIED="1512359008205" TEXT="piggyback?">
<icon BUILTIN="help"/>
<node CREATED="1512358616584" ID="ID_1041373923" MODIFIED="1512358662699" TEXT="&quot;k&#xf6;nnte mal praktisch sein&quot;">
@ -6329,9 +6356,67 @@
<icon BUILTIN="ksmiletris"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1511836589393" ID="ID_54165230" MODIFIED="1511836592073" TEXT="verify_asIterSource();">
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1511836589393" ID="ID_54165230" MODIFIED="1512621159744" TEXT="verify_asIterSource();">
<icon BUILTIN="pencil"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1512620990860" ID="ID_167384287" MODIFIED="1512621374577" TEXT="einfach verpacken">
<icon BUILTIN="flag-yellow"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1512620997827" ID="ID_173233581" MODIFIED="1512621372921" TEXT="erzeugte source erneut verpacken">
<icon BUILTIN="flag-yellow"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1512621101645" ID="ID_1982135306" MODIFIED="1512621376089" TEXT="polymorphie: verschiedene Pipelines">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
verschiedendste Pipeline-Konstruktionen
</p>
<p>
k&#246;nnen nun hinter dem gleichen Interface sitzen
</p>
</body>
</html>
</richcontent>
<icon BUILTIN="flag-yellow"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1512621116947" ID="ID_1907769466" MODIFIED="1512621378248" TEXT="durchgeschleifte expandChildren()-Operation">
<icon BUILTIN="flag-yellow"/>
</node>
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1512621383815" ID="ID_1705587551" MODIFIED="1512621486222" TEXT="Problem: shallow copy">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
rein ein Problem mit der Test-Fixture.
</p>
<p>
Da die Quelle nun von einem shared-ptr gehalten wird,
</p>
<p>
erzeugt eine Kopie des Iterator-Front-End
</p>
<p>
nun nicht mehr eine Kopie des ganzen Zustandes.
</p>
<p>
</p>
<p>
das w&#228;re aber bequem f&#252;r den Test.
</p>
<p>
<u>Frage</u>: ist das &#252;berhaupt eine gute Idee, vom Design her??
</p>
</body>
</html>
</richcontent>
<icon BUILTIN="messagebox_warning"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1510969031379" ID="ID_1327871737" MODIFIED="1510969042972" TEXT="verify_depthFirstExploration();">
<icon BUILTIN="flag-yellow"/>
</node>