diff --git a/src/common/advice.hpp b/src/common/advice.hpp
index cd3dde870..7bce7893e 100644
--- a/src/common/advice.hpp
+++ b/src/common/advice.hpp
@@ -148,7 +148,7 @@ namespace advice {
explicit
PointOfAdvice (Binding const& binding)
: pattern_(binding.buildMatcher())
- , resolution_(0)
+ , resolution_(nullptr)
{ }
// using default copy/assignment
@@ -291,6 +291,12 @@ namespace advice {
discardSolutions();
}
+ bool
+ isGiven() const
+ {
+ return bool{this->getSolution()};
+ }
+
void
defineBinding (Literal topic)
{
@@ -413,7 +419,7 @@ namespace advice {
* Access point for the advised entity (client).
* This is the interface intended for client code to request advice
* of a specific type and optionally limited to a special topic (binding).
- * Instantiating an \c Request object automatically entails a registration
+ * Instantiating an `Request` object automatically entails a registration
* with the AdviceSystem behind the scenes, and deleting it causes deregistration.
* Request objects may be instantiated and copied freely, and the binding pattern
* may be changed. The actual advice is accessed through the member function
@@ -470,6 +476,18 @@ namespace advice {
}
+ /**
+ * @return `true` if this request retrieves a piece of information specifically set
+ * by an Advisor, as opposed to just delivering a default fallback result.
+ */
+ bool
+ isMatched() const
+ {
+ return bool{this->getSolution()};
+ }
+
+
+ /** set and possibly change the binding term used to retrieve Advice */
void
defineBinding (Literal topic)
{
diff --git a/tests/25fundamental.tests b/tests/25fundamental.tests
index f42fe79cb..ab68f6ecf 100644
--- a/tests/25fundamental.tests
+++ b/tests/25fundamental.tests
@@ -12,7 +12,7 @@ return: 0
END
-PLANNED "Advice constellations" AdviceSituations_test <
-
-//using lib::test::showSizeof;
-//using lib::test::randStr;
-//using util::isSameObject;
-//using util::and_all;
-//using util::for_each;
-//using util::isnil;
-//using lib::Literal;
-//using lib::Symbol;
-//using liab::P;
-//using std::string;
-
namespace lumiera {
@@ -67,7 +45,7 @@ namespace test {
* @test documentation of the fundamental usage scenarios envisioned in the Advice concept.
* This test will be augmented and completed as the Lumiera application matures.
*
- * @todo partially unimplemented and thus commented out ////////////////////TICKET #335
+ * @todo yet more use cases to come.... ////////////////////////////////////////////////////////TICKET #335
*
* @see advice.hpp
* @see AdviceBasics_test
@@ -79,31 +57,85 @@ namespace test {
virtual void
run (Arg)
{
- check_ProxyRenderingAdvice();
- check_DependencyInjection();
+ pattern01_justPickAndBeHappy();
+ pattern02_pickIfPresent();
+ pattern03_installOnlyOnce();
TODO ("more advice usage scenarios.....?");
}
- /** @test usage scenario: switch a processing node into proxy mode. */
+ /** @test usage pattern 01: simply consume Advice -- irrespective if set explicitly. */
void
- check_ProxyRenderingAdvice()
+ pattern01_justPickAndBeHappy()
{
- UNIMPLEMENTED ("anything regarding proxy rendering");
-#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #335
-#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #335
+ Request generic{"solution(life_and_universe_and_everything)"};
+ CHECK (0 == generic.getAdvice()); // the early bird gets the worm...
+
+ Provision universal{"solution(life_and_universe_and_everything)"};
+ universal.setAdvice(5);
+ CHECK (5 == generic.getAdvice()); // ...while the bad girls go everywhere
+
+ universal.retractAdvice();
+ CHECK (0 == generic.getAdvice()); // nothing to see here, just move on
}
- /** @test usage scenario: dependency injection for tests */
+ /** @test usage pattern 01: detect if specific advice was given. */
void
- check_DependencyInjection()
+ pattern02_pickIfPresent()
{
- UNIMPLEMENTED ("suitable advice to request and transfer test dependencies");
-#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #335
-#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #335
+ Request request{"something(special)"};
+ CHECK (not request.isMatched());
+
+ Provision info{"something(special)"};
+ info.setAdvice(55);
+ CHECK (request.isMatched());
+ CHECK (55 == request.getAdvice());
+
+ info.retractAdvice();
+ CHECK (not request.isMatched());
}
+
+ /** @test usage pattern 01: . */
+ void
+ pattern03_installOnlyOnce()
+ {
+ Provision info{"something(special)"};
+ CHECK (not info.isGiven());
+
+ Request question{"something(special)"};
+ CHECK (0 == question.getAdvice());
+ CHECK (not question.isMatched());
+
+ auto publish = [&](int i)
+ {
+ if (not info.isGiven())
+ info.setAdvice (i);
+ };
+
+ for (uint i=0; i<5; ++i)
+ if (i % 2)
+ publish (i);
+
+ CHECK (1 == question.getAdvice());
+ CHECK (question.isMatched());
+
+ info.retractAdvice();
+ CHECK (not info.isGiven());
+ CHECK (not question.isMatched());
+ }
+
+
+#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #335
+ /** @test usage pattern ∞ : somewhat literally fantastic */
+ void
+ check_SevenMoreWondersOfTheWorld()
+ {
+ UNIMPLEMENTED ("suitable advice to save the world");
+ }
+#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #335
+
// more to come.....
};
diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm
index 4c4f9bac2..9927c04ea 100644
--- a/wiki/thinkPad.ichthyo.mm
+++ b/wiki/thinkPad.ichthyo.mm
@@ -6089,7 +6089,7 @@
-
+
@@ -6112,6 +6112,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -18158,6 +18210,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ die Vertiefungen im Anzeige-Profil
+
+
+ auf der rechten Seite, wo der Content angezeigt wird
+
+
+
+
+
+
+
+
+
+
@@ -19182,7 +19281,7 @@
-
+
@@ -19193,13 +19292,13 @@
-
+
-
-
+
+
@@ -19269,6 +19368,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -21383,8 +21498,8 @@
-
-
+
+
@@ -21519,6 +21634,10 @@
+
+
+
+
@@ -21559,7 +21678,8 @@
-
+
+
@@ -21593,11 +21713,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -21809,7 +21946,8 @@
-
+
+
@@ -21833,6 +21971,12 @@
+
+
+
+
+
+
@@ -39242,7 +39386,7 @@
-
+
@@ -39542,7 +39686,7 @@
-
+
@@ -40058,7 +40202,7 @@
-
+
@@ -40853,7 +40997,7 @@
-
+
@@ -40956,7 +41100,7 @@
-
+
@@ -41535,7 +41679,7 @@
-
+
@@ -41571,9 +41715,10 @@
-
+
+
-
+
@@ -41816,7 +41961,7 @@
-
+
@@ -41906,7 +42051,7 @@
-
+
@@ -41931,7 +42076,164 @@
-
+
+
+
+
+
+
+
+
+ das «Regel-System»
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ das «Advice-System»
+
+
+
+
+
+
+
+
+
+
+
+
+
+ auch in 2019...
+
+
+ -
+ nur einige sporadische Use-Cases
+
+ -
+ ich halte es aber weiterhin für wichtig
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ein Whiteboard-System
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ....denn es gibt die default-Lösung
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ im Sinne des Erfinders...
+
+
+ bloß jetzt etwas abstrakter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+