42 using control::CmdClosure;
43 using LERR_(MISSING_MEMENTO);
44 using LERR_(UNBOUND_ARGUMENTS);
88 checkStateCapturingMechanism();
99 typedef void SIG_fun(
int);
100 function<SIG_fun> funky = testFunc;
105 CHECK (not nullClosure.
isValid());
106 cout <<
"empty placeholder closure: " << nullClosure << endl;
107 VERIFY_ERROR (UNBOUND_ARGUMENTS, functor(nullClosure) );
116 cout <<
"param values: " << closure << endl;
144 function<void(int)> undo_func = testFunc;
145 function<int(void)> cap_func = capture;
149 MemHolder mementoHolder (undo_func,cap_func);
151 CHECK (!mementoHolder);
154 VERIFY_ERROR (UNBOUND_ARGUMENTS, undoFunctor(nullClosure) );
155 VERIFY_ERROR (UNBOUND_ARGUMENTS, undoFunctor.captureState(nullClosure) );
160 CHECK (!mementoHolder);
162 VERIFY_ERROR (MISSING_MEMENTO, mementoHolder.getState() );
165 undoFunctor.captureState(clo);
166 CHECK (mementoHolder);
167 CHECK (testVal == 11);
169 int mem = mementoHolder.getState();
170 cout <<
"saved state: " << mem << endl;
173 CHECK (testVal == 11 + 11);
175 CHECK (testVal == 11 + 11 + 11);
176 undoFunctor.captureState(clo);
177 CHECK (33 == mementoHolder.getState());
179 CHECK (testVal == 33 + 33);
182 CHECK (testVal == 42);
193 MemHolder mementoHolder (testFunc, capture);
195 function<void()> bound_undo_func = mementoHolder.tieUndoFunc();
196 function<void()> bound_cap_func = mementoHolder.tieCaptureFunc();
202 CHECK (rr == mementoHolder.getState());
206 CHECK (testVal == 10+rr);
int testVal
used to verify the effect of testFunc
A template metaprogramming technique for manipulating collections of types.
typename BuildTupleType< TYPES >::Type Tuple
Build a std::tuple from types given as type sequence.
Core of a Steam-Layer command: functor containing the operation to be executed.
Proof-of-concept implementation of CmdClosure.
int rani(uint bound=_iBOUND())
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
Steam-Layer implementation namespace root.
Metaprogramming with tuples-of-types and the std::tuple record.
Specialised version of the command Mutation functor, used to implement the UNDO functionality.
A special binding used by Steam-Layer commands for capturing UNDO state information.
void checkStateCapturingMechanism()
Simplistic test class runner.
Dummy / proof-of-concept implementation of CmdClosure.
A collection of frequently used helper functions to support unit testing.
Unspecific command functor for implementing Steam-Layer Command.
virtual bool isValid() const override
does this closure hold a valid argument tuple?
Binding together state capturing and execution of the undo operation.
Verify the behaviour of the type erased closure, which is used by Steam-Layer commands to implement t...