TreeExplorer: first testcase, build either from Lumiera-Iterator or use StateCore
TODO: also wrap any suitable STL iterable. we need a one-shot solution here
This commit is contained in:
parent
fe3feee67a
commit
fd3d6fb60e
3 changed files with 48 additions and 23 deletions
|
|
@ -73,7 +73,7 @@
|
||||||
|
|
||||||
#include "lib/error.hpp"
|
#include "lib/error.hpp"
|
||||||
#include "lib/meta/trait.hpp"
|
#include "lib/meta/trait.hpp"
|
||||||
//#include "lib/meta/function.hpp"
|
#include "lib/meta/duck-detector.hpp"
|
||||||
#include "lib/iter-adapter.hpp"
|
#include "lib/iter-adapter.hpp"
|
||||||
#include "lib/iter-stack.hpp"
|
#include "lib/iter-stack.hpp"
|
||||||
#include "lib/meta/trait.hpp" ////////////////TODO
|
#include "lib/meta/trait.hpp" ////////////////TODO
|
||||||
|
|
@ -159,15 +159,24 @@ namespace lib {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using meta::enable_if;
|
using meta::enable_if;
|
||||||
|
using meta::Yes_t;
|
||||||
|
using meta::No_t;
|
||||||
using std::__and_;
|
using std::__and_;
|
||||||
using std::__not_;
|
using std::__not_;
|
||||||
using std::is_constructible;
|
using std::is_constructible;
|
||||||
using meta::can_IterForEach;
|
using meta::can_IterForEach;
|
||||||
using meta::can_STL_ForEach;
|
using meta::can_STL_ForEach;
|
||||||
|
|
||||||
|
META_DETECT_EXTENSION_POINT(checkPoint);
|
||||||
|
META_DETECT_EXTENSION_POINT(iterNext);
|
||||||
|
META_DETECT_EXTENSION_POINT(yield);
|
||||||
|
|
||||||
template<class SRC>
|
template<class SRC>
|
||||||
struct is_StateCore
|
struct is_StateCore
|
||||||
: is_constructible<lib::IterStateWrapper<typename SRC::value_type, SRC>, SRC>
|
: __and_< HasExtensionPoint_checkPoint<SRC const&>
|
||||||
|
, HasExtensionPoint_iterNext<SRC &>
|
||||||
|
, HasExtensionPoint_yield<SRC const&>
|
||||||
|
>
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
template<class SRC>
|
template<class SRC>
|
||||||
|
|
@ -187,13 +196,14 @@ namespace lib {
|
||||||
template<class SRC>
|
template<class SRC>
|
||||||
struct _TreeExplorerTraits<SRC, enable_if<is_StateCore<SRC>>>
|
struct _TreeExplorerTraits<SRC, enable_if<is_StateCore<SRC>>>
|
||||||
{
|
{
|
||||||
static_assert (!sizeof(SRC), "PLING: StateCore");
|
using SrcVal = typename std::remove_reference<decltype(yield (std::declval<SRC>()))>::type;
|
||||||
|
using SrcIter = IterStateWrapper<SrcVal, SRC>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class SRC>
|
template<class SRC>
|
||||||
struct _TreeExplorerTraits<SRC, enable_if<can_IterForEach<SRC>>>
|
struct _TreeExplorerTraits<SRC, enable_if<can_IterForEach<SRC>>>
|
||||||
{
|
{
|
||||||
static_assert (!sizeof(SRC), "PLING: Lumi Iter");
|
using SrcIter = typename std::remove_reference<SRC>::type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class SRC>
|
template<class SRC>
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ namespace test{
|
||||||
uint p,e;
|
uint p,e;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
State(uint start, uint end)
|
State(uint start =0, uint end =0)
|
||||||
: p(start)
|
: p(start)
|
||||||
, e(end)
|
, e(end)
|
||||||
{ }
|
{ }
|
||||||
|
|
@ -99,7 +99,7 @@ namespace test{
|
||||||
friend bool
|
friend bool
|
||||||
checkPoint (State const& st)
|
checkPoint (State const& st)
|
||||||
{
|
{
|
||||||
return st.p < st.e;
|
return st.p > st.e;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend uint&
|
friend uint&
|
||||||
|
|
@ -111,8 +111,8 @@ namespace test{
|
||||||
friend void
|
friend void
|
||||||
iterNext (State & st)
|
iterNext (State & st)
|
||||||
{
|
{
|
||||||
if (!checkPoint(st)) return;
|
if (not checkPoint(st)) return;
|
||||||
++st.p;
|
--st.p;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -248,12 +248,11 @@ namespace test{
|
||||||
void
|
void
|
||||||
verify_wrappedState()
|
verify_wrappedState()
|
||||||
{
|
{
|
||||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1117
|
auto ii = treeExplore (State{5,0});
|
||||||
auto ii = treeExplore (State{1,5});
|
|
||||||
CHECK (!isnil (ii));
|
CHECK (!isnil (ii));
|
||||||
CHECK (1 == *ii);
|
CHECK (5 == *ii);
|
||||||
++ii;
|
++ii;
|
||||||
CHECK (2 == *ii);
|
CHECK (4 == *ii);
|
||||||
pullOut(ii);
|
pullOut(ii);
|
||||||
CHECK ( isnil (ii));
|
CHECK ( isnil (ii));
|
||||||
CHECK (!ii);
|
CHECK (!ii);
|
||||||
|
|
@ -261,14 +260,13 @@ namespace test{
|
||||||
VERIFY_ERROR (ITER_EXHAUST, *ii );
|
VERIFY_ERROR (ITER_EXHAUST, *ii );
|
||||||
VERIFY_ERROR (ITER_EXHAUST, ++ii );
|
VERIFY_ERROR (ITER_EXHAUST, ++ii );
|
||||||
|
|
||||||
ii = treeExplore (State{0,5});
|
ii = treeExplore (State{5});
|
||||||
CHECK (materialise(ii) == "0-1-2-3-4-5");
|
CHECK (materialise(ii) == "5-4-3-2-1");
|
||||||
ii = treeExplore (State{5,7});
|
ii = treeExplore (State{7,4});
|
||||||
CHECK (materialise(ii) == "5-6-7");
|
CHECK (materialise(ii) == "7-6-5");
|
||||||
ii = treeExplore (State{1,0});
|
ii = treeExplore (State{});
|
||||||
CHECK ( isnil (ii));
|
CHECK ( isnil (ii));
|
||||||
CHECK (!ii);
|
CHECK (!ii);
|
||||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1117
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -276,7 +274,6 @@ namespace test{
|
||||||
void
|
void
|
||||||
verify_wrappedIterator()
|
verify_wrappedIterator()
|
||||||
{
|
{
|
||||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1117
|
|
||||||
vector<int> numz{1,-2,3,-5,8,-13};
|
vector<int> numz{1,-2,3,-5,8,-13};
|
||||||
auto ii = eachElm(numz);
|
auto ii = eachElm(numz);
|
||||||
CHECK (!isnil (ii));
|
CHECK (!isnil (ii));
|
||||||
|
|
@ -294,8 +291,7 @@ namespace test{
|
||||||
CHECK (-2 == *ii);
|
CHECK (-2 == *ii);
|
||||||
|
|
||||||
CHECK (materialise(ii) == "-2-3--5-8--13");
|
CHECK (materialise(ii) == "-2-3--5-8--13");
|
||||||
CHECK (materialise(jj) == "-3--5-8--13");
|
CHECK (materialise(jj) == "3--5-8--13");
|
||||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1117
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -306,8 +302,6 @@ namespace test{
|
||||||
verify_mapOperation()
|
verify_mapOperation()
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED("map function onto the results");
|
UNIMPLEMENTED("map function onto the results");
|
||||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1117
|
|
||||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1117
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5094,6 +5094,9 @@
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1510941455667" ID="ID_1945607867" MODIFIED="1510941522371" TEXT="Builder">
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1510941455667" ID="ID_1945607867" MODIFIED="1510941522371" TEXT="Builder">
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="flag-yellow"/>
|
||||||
|
<node CREATED="1511054840038" ID="ID_18464349" MODIFIED="1511054851543" TEXT="brauch ich am Ende überhaupt einen builder">
|
||||||
|
<icon BUILTIN="help"/>
|
||||||
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1510941463562" ID="ID_845080696" MODIFIED="1510941523082" TEXT="TreeExplorer">
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1510941463562" ID="ID_845080696" MODIFIED="1510941523082" TEXT="TreeExplorer">
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="flag-yellow"/>
|
||||||
|
|
@ -5102,6 +5105,24 @@
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="flag-yellow"/>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1510969031378" ID="ID_1678287752" MODIFIED="1510969040176" TEXT="verify_wrappedIterator();">
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1510969031378" ID="ID_1678287752" MODIFIED="1510969040176" TEXT="verify_wrappedIterator();">
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="flag-yellow"/>
|
||||||
|
<node CREATED="1511054727547" ID="ID_328168347" MODIFIED="1511054858441" TEXT="Problem: muß Iterator-Arten unterscheiden">
|
||||||
|
<icon BUILTIN="messagebox_warning"/>
|
||||||
|
</node>
|
||||||
|
<node COLOR="#338800" CREATED="1511054740579" ID="ID_776471136" MODIFIED="1511054761188" TEXT="StateCore direkt verwenden">
|
||||||
|
<icon BUILTIN="button_ok"/>
|
||||||
|
<node CREATED="1511054762608" ID="ID_1129026084" MODIFIED="1511054793514" TEXT="muß IterStateWrapper unterstützen">
|
||||||
|
<icon BUILTIN="info"/>
|
||||||
|
</node>
|
||||||
|
<node COLOR="#338800" CREATED="1511054775616" ID="ID_1071927856" MODIFIED="1511054795068" TEXT="Metafuntkion um Erweiterungspunkte zu erkennen">
|
||||||
|
<icon BUILTIN="button_ok"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
<node COLOR="#338800" CREATED="1511054800851" ID="ID_186154206" MODIFIED="1511054827673" TEXT="Lumiera-Iterator verwenden">
|
||||||
|
<icon BUILTIN="button_ok"/>
|
||||||
|
</node>
|
||||||
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1511054810307" ID="ID_418847335" MODIFIED="1511054825261" TEXT="Range-iter um STL -iterable legen">
|
||||||
|
<icon BUILTIN="flag-yellow"/>
|
||||||
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1510969031379" ID="ID_358406634" MODIFIED="1510969041003" TEXT="verify_mapOperation();">
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1510969031379" ID="ID_358406634" MODIFIED="1510969041003" TEXT="verify_mapOperation();">
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="flag-yellow"/>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue