51 using control::CmdClosure;
52 using LERR_(MISSING_MEMENTO);
53 using LERR_(UNBOUND_ARGUMENTS);
95 checkStateCapturingMechanism();
106 typedef void SIG_fun(
int);
107 function<SIG_fun> funky = testFunc;
112 CHECK (not nullClosure.
isValid());
113 cout <<
"empty placeholder closure: " << nullClosure << endl;
114 VERIFY_ERROR (UNBOUND_ARGUMENTS, functor(nullClosure) );
123 cout <<
"param values: " << closure << endl;
151 function<void(int)> undo_func = testFunc;
152 function<int(void)> cap_func = capture;
156 MemHolder mementoHolder (undo_func,cap_func);
158 CHECK (!mementoHolder);
161 VERIFY_ERROR (UNBOUND_ARGUMENTS, undoFunctor(nullClosure) );
162 VERIFY_ERROR (UNBOUND_ARGUMENTS, undoFunctor.captureState(nullClosure) );
167 CHECK (!mementoHolder);
169 VERIFY_ERROR (MISSING_MEMENTO, mementoHolder.getState() );
172 undoFunctor.captureState(clo);
173 CHECK (mementoHolder);
174 CHECK (testVal == 11);
176 int mem = mementoHolder.getState();
177 cout <<
"saved state: " << mem << endl;
180 CHECK (testVal == 11 + 11);
182 CHECK (testVal == 11 + 11 + 11);
183 undoFunctor.captureState(clo);
184 CHECK (33 == mementoHolder.getState());
186 CHECK (testVal == 33 + 33);
189 CHECK (testVal == 42);
200 MemHolder mementoHolder (testFunc, capture);
202 function<void()> bound_undo_func = mementoHolder.tieUndoFunc();
203 function<void()> bound_cap_func = mementoHolder.tieCaptureFunc();
206 int rr (rand() % 100);
209 CHECK (rr == mementoHolder.getState());
213 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.
#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()
Simple 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...