From 0ab5a926297dd0480ca1b73ea38e7ce44ecfdb52 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 19 Jun 2009 05:57:06 +0200 Subject: [PATCH] WIP: test-driven brainstorming... how to capture state and params. --- src/proc/control/command-def.hpp | 4 +- src/proc/control/mutation.hpp | 61 +++++ tests/45controller.tests | 3 +- tests/components/Makefile.am | 1 + .../proc/control/command-basic-test.cpp | 45 ++-- .../proc/control/command-mutation-test.cpp | 212 ++++++++++++++++++ 6 files changed, 297 insertions(+), 29 deletions(-) create mode 100644 tests/components/proc/control/command-mutation-test.cpp diff --git a/src/proc/control/command-def.hpp b/src/proc/control/command-def.hpp index a6b6c2c1d..0f02e9046 100644 --- a/src/proc/control/command-def.hpp +++ b/src/proc/control/command-def.hpp @@ -44,8 +44,8 @@ -#ifndef CONTROL_COMMAND_H -#define CONTROL_COMMAND_H +#ifndef CONTROL_COMMAND_DEF_H +#define CONTROL_COMMAND_DEF_H //#include "pre.hpp" #include "include/symbol.hpp" diff --git a/src/proc/control/mutation.hpp b/src/proc/control/mutation.hpp index d0791ecd2..04f1daf54 100644 --- a/src/proc/control/mutation.hpp +++ b/src/proc/control/mutation.hpp @@ -36,6 +36,7 @@ #define CONTROL_MUTATION_H //#include "pre.hpp" +#include "lib/error.hpp" //#include @@ -54,10 +55,53 @@ namespace control { { public: + template + Mutation (function const& func) + { + UNIMPLEMENTED ("build a Mutation functor object, thereby erasing the concrete function signature type"); + } + virtual ~Mutation() {} + + virtual Mutation& + close (CmdClosure const& closure) + { + UNIMPLEMENTED ("accept and store a parameter closure"); + } + + void + operator() () + { + UNIMPLEMENTED ("invoke the Mutation functor"); + } + + + /* == diagnostics == */ + typedef pClo Mutation::*_unspecified_bool_type; + + /** implicit conversion to "bool" */ + operator _unspecified_bool_type() const { return isValid()? &Mutation::clo_ : 0; } // never throws + bool operator! () const { return !isValid(); } // ditto + + operator string() const + { + return isValid()? string (*clo) : "Mutation(state missing)"; + } + + protected: + virtual bool + isValid () + { + UNIMPLEMENTED ("mutation lifecycle"); + } }; + inline ostream& operator<< (ostream& os, const Mutation& muta) { return os << string(muta); } + + + + /** * @todo Type-comment */ @@ -66,6 +110,23 @@ namespace control { { public: + template + UndoMutation (function const& func) + { + UNIMPLEMENTED ("build a undo Mutation functor object"); + } + + Mutation& + captureState () + { + UNIMPLEMENTED ("invoke the state capturing Functor"); + } + + CmdClosure& + getMemento() + { + UNIMPLEMENTED ("return the closure serving as memento"); + } }; ////////////////TODO currently just fleshing out the API.... diff --git a/tests/45controller.tests b/tests/45controller.tests index f1cca4d94..b49080ee9 100644 --- a/tests/45controller.tests +++ b/tests/45controller.tests @@ -7,4 +7,5 @@ PLANNED "CommandBasic_test" CommandBasic_test < op(void) - - curry(opFunc) (a) (b) (c) - - pAppl(func, x) -> func2 (b, c) - - return bind( recursion(), param) - -*/ + + namespace command1 { void operate (P