MutationMessage: implementation draft
This commit is contained in:
parent
f0de986399
commit
76fc444437
5 changed files with 117 additions and 10 deletions
|
|
@ -73,7 +73,7 @@ namespace ctrl {
|
|||
}
|
||||
|
||||
|
||||
MutationMessage::~MutationMessage() { }
|
||||
diff_msg::Holder::~Holder() { }
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -52,12 +52,14 @@
|
|||
|
||||
#include "lib/error.hpp"
|
||||
//#include "lib/symbol.hpp"
|
||||
#include "lib/opaque-holder.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
//#include "lib/idi/entry-id.hpp"
|
||||
#include "lib/diff/diff-mutable.hpp"
|
||||
|
||||
//#include <boost/noncopyable.hpp>
|
||||
//#include <utility>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
|
@ -73,6 +75,42 @@ namespace ctrl{
|
|||
// using lib::diff::GenNode;
|
||||
using std::string;
|
||||
|
||||
namespace diff_msg {
|
||||
|
||||
class Holder
|
||||
{
|
||||
public:
|
||||
virtual ~Holder(); ///< this is an interface
|
||||
virtual void applyTo (lib::diff::DiffMutable&) =0;
|
||||
virtual string describe() const =0;
|
||||
};
|
||||
|
||||
template<typename DIFF>
|
||||
class Wrapped
|
||||
: public Holder
|
||||
{
|
||||
DIFF diff_;
|
||||
|
||||
virtual void
|
||||
applyTo (lib::diff::DiffMutable& target) override
|
||||
{
|
||||
UNIMPLEMENTED("how to embed a diff sequence and apply this to the target");
|
||||
}
|
||||
|
||||
virtual string
|
||||
describe() const override
|
||||
{
|
||||
UNIMPLEMENTED("string representation of diff/mutation messages");
|
||||
}
|
||||
|
||||
public:
|
||||
Wrapped (DIFF&& diffSeq)
|
||||
: diff_(std::move(diffSeq))
|
||||
{ }
|
||||
};
|
||||
|
||||
using Buffer = lib::InPlaceBuffer<Holder>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Message on the UI-Bus holding an embedded diff sequence.
|
||||
|
|
@ -80,21 +118,25 @@ namespace ctrl{
|
|||
* to expose a TreeMutator, and then apply the embedded diff.
|
||||
*/
|
||||
class MutationMessage
|
||||
: public diff_msg::Buffer
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
virtual ~MutationMessage(); ///< this is an interface
|
||||
template<typename DIFF>
|
||||
MutationMessage(DIFF&& diffSeq)
|
||||
: diff_msg::Buffer{ embedType<diff_msg::Wrapped<DIFF>>()
|
||||
, std::move(diffSeq)}
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
void
|
||||
applyTo (lib::diff::DiffMutable& target)
|
||||
{
|
||||
UNIMPLEMENTED("how to embed a diff sequence and apply this to the target");
|
||||
access<diff_msg::Holder>()->applyTo(target);
|
||||
}
|
||||
|
||||
operator string() const
|
||||
{
|
||||
UNIMPLEMENTED("string representation of diff/mutation messages");
|
||||
return unConst(this)->access<diff_msg::Holder>()->describe();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ using lib::diff::DataCap;
|
|||
using proc::control::Command;
|
||||
using proc::control::CommandDef;
|
||||
using gui::interact::InvocationTrail;
|
||||
using gui::ctrl::MutationMessage;
|
||||
|
||||
|
||||
|
||||
|
|
@ -580,8 +581,8 @@ namespace test {
|
|||
MockElm rootMock("root");
|
||||
ID rootID = rootMock.getID();
|
||||
|
||||
rootMock["α"] = "Centauri";
|
||||
CHECK ("Centauri" == rootMock["α"]);
|
||||
rootMock.attrib["α"] = "Centauri";
|
||||
CHECK ("Centauri" == rootMock.attrib["α"]);
|
||||
CHECK (isnil (rootMock.scope));
|
||||
|
||||
|
||||
|
|
@ -626,10 +627,10 @@ namespace test {
|
|||
<< "\n───╼━━━━━━━━━╾────────────────"<<endl;
|
||||
|
||||
CHECK (2 == rootMock.scope.size()); // we've got two children now
|
||||
CHECK (rootMock["α"] == "quadrant"); // alpha attribute has been reassigned
|
||||
CHECK (rootMock.attrib["α"] == "quadrant"); // alpha attribute has been reassigned
|
||||
CHECK (rootMock.scope[0].getID() == diffSrc.CHILD_1.idi); // children have the expected IDs
|
||||
CHECK (rootMock.scope[1].getID() == diffSrc.CHILD_2.idi);
|
||||
CHECK (rootMock.scope[1]["π"] == "3.1415927"); // and the second child got attribute Pi
|
||||
CHECK (rootMock.scope[1].attrib["π"] == "3.1415927"); // and the second child got attribute Pi
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@
|
|||
#include "lib/util.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
|
||||
namespace gui {
|
||||
|
|
@ -112,6 +114,7 @@ namespace test{
|
|||
string error_;
|
||||
|
||||
|
||||
|
||||
/* ==== Tangible interface ==== */
|
||||
|
||||
virtual bool
|
||||
|
|
@ -295,6 +298,12 @@ namespace test{
|
|||
|
||||
|
||||
|
||||
/* ==== Attributes and mock children ==== */
|
||||
|
||||
std::map<string, string> attrib;
|
||||
std::vector<MockElm> scope;
|
||||
|
||||
|
||||
/* ==== Query/Verification API ==== */
|
||||
|
||||
ID getID() const
|
||||
|
|
|
|||
|
|
@ -5590,6 +5590,61 @@
|
|||
<node CREATED="1475356059342" ID="ID_1039482059" MODIFIED="1475356066062" TEXT="wie wird Diff eingebettet">
|
||||
<icon BUILTIN="help"/>
|
||||
</node>
|
||||
<node CREATED="1475439403514" ID="ID_1619035258" MODIFIED="1475439643157" TEXT="Entscheidung">
|
||||
<icon BUILTIN="yes"/>
|
||||
<node CREATED="1475439416185" ID="ID_963854956" MODIFIED="1475439565484" TEXT="Builder-Funktion nicht sinnvoll">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
....denn dann müßte der Benutzer die Mechanik sehr genau verstehen, und stets eine auto-Variable definieren.
|
||||
</p>
|
||||
<p>
|
||||
Sinnvoll wäre dieser Ansatz nur, wenn das UI-Bus-API eine MutationMessage const& nehmen würde,
|
||||
</p>
|
||||
<p>
|
||||
denn dann könnte man den Builder-Aufruf inline schreiben.
|
||||
</p>
|
||||
<p>
|
||||
Da wir aber stets den Diff moven und dann iterieren, scheidet const& aus
|
||||
</p>
|
||||
<p>
|
||||
Und für eine reine Ref erzeugt C++ niemals eine anonyme Instanz!
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</node>
|
||||
<node CREATED="1475439429055" ID="ID_1383518557" MODIFIED="1475439634154" TEXT="also: embeded Buffer">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
...und diesen mit VTable bestücken.
|
||||
</p>
|
||||
<p>
|
||||
Dafür wird die äußere Hülle non-virtual
|
||||
</p>
|
||||
<p>
|
||||
und kann noncopyable gemacht werden..
|
||||
</p>
|
||||
<p>
|
||||
Das erlaubt dem Benutzer, einfach zu schreiben
|
||||
</p>
|
||||
<p>
|
||||
MutationMessage(blaBlubb())
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
<icon BUILTIN="ksmiletris"/>
|
||||
</node>
|
||||
<node CREATED="1475439436134" ID="ID_583247605" MODIFIED="1475439442228" TEXT="verwende InPlaceBuffer"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1475356066853" ID="ID_821643910" MODIFIED="1475356076468" TEXT="Problem: Puffergröße">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
|
|
|
|||
Loading…
Reference in a new issue