51 using control::CmdClosure;
93 checkStateCapturingMechanism();
104 typedef void SIG_fun(
int);
105 function<SIG_fun> funky = testFunc;
110 CHECK (not nullClosure.
isValid());
111 cout <<
"empty placeholder closure: " << nullClosure << endl;
112 VERIFY_ERROR (UNBOUND_ARGUMENTS, functor(nullClosure) );
121 cout <<
"param values: " << closure << endl;
149 function<void(int)> undo_func = testFunc;
150 function<int(void)> cap_func = capture;
154 MemHolder mementoHolder (undo_func,cap_func);
156 CHECK (!mementoHolder);
159 VERIFY_ERROR (UNBOUND_ARGUMENTS, undoFunctor(nullClosure) );
160 VERIFY_ERROR (UNBOUND_ARGUMENTS, undoFunctor.captureState(nullClosure) );
165 CHECK (!mementoHolder);
167 VERIFY_ERROR (MISSING_MEMENTO, mementoHolder.getState() );
170 undoFunctor.captureState(clo);
171 CHECK (mementoHolder);
172 CHECK (testVal == 11);
174 int mem = mementoHolder.getState();
175 cout <<
"saved state: " << mem << endl;
178 CHECK (testVal == 11 + 11);
180 CHECK (testVal == 11 + 11 + 11);
181 undoFunctor.captureState(clo);
182 CHECK (33 == mementoHolder.getState());
184 CHECK (testVal == 33 + 33);
187 CHECK (testVal == 42);
198 MemHolder mementoHolder (testFunc, capture);
200 function<void()> bound_undo_func = mementoHolder.tieUndoFunc();
201 function<void()> bound_cap_func = mementoHolder.tieCaptureFunc();
204 int rr (rand() % 100);
207 CHECK (rr == mementoHolder.getState());
211 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 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...