40 #ifndef CONTROL_MEMENTO_TIE_H 41 #define CONTROL_MEMENTO_TIE_H 50 #include <boost/operators.hpp> 58 using boost::equality_comparable;
61 using lib::meta::equals_safeInvoke;
88 template<
typename SIG,
typename MEM>
90 :
public equality_comparable<MementoTie<SIG,MEM>>
92 typedef typename CommandSignature<SIG,MEM>::CaptureSig SIG_cap;
93 typedef typename CommandSignature<SIG,MEM>::UndoOp_Sig SIG_undo;
99 function<SIG_undo> undo_;
100 function<SIG_cap> capture_;
106 memento_ = mementoVal;
113 :
MementoTie (function<SIG_undo>(), function<SIG_cap>())
122 function<SIG_cap>
const& captureFunc)
126 , capture_(captureFunc)
151 return bindLast( undo_
164 using std::placeholders::_1;
168 return chained(capture_, doCaptureMemento);
180 LERR_(MISSING_MEMENTO));
190 operator bool()
const 198 return undo_ && capture_ && isCaptured_;
202 operator std::string()
const;
207 template<
typename SIG,
typename MEM>
210 if (!undo_ || !capture_)
214 return "<mem:missing>";
function< SIG > tieCaptureFunc()
bind the capturing function to the internal memento store within this object.
helpers for fail-safe invocation of comparison operations from generic code.
function< SIG > tieUndoFunc()
bind the undo function to the internal memento store within this object.
Partial function application and building a complete function closure.
Steam-Layer implementation namespace root.
Derived specific exceptions within Lumiera's exception hierarchy.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
void capture(MEM const &mementoVal)
to be chained behind the capture function
LUMIERA_ERROR_DECLARE(INVALID_ARGUMENTS)
Arguments provided for binding doesn't match stored command function parameters.
_PapE< SIG >::Function bindLast(SIG &f, TERM const &arg)
bind the last function argument to an arbitrary term, which especially might be a (nested) binder...
void clear()
reverses the effect of capturing state and returns this memento holder into pristine state ...
_Chain< SIG1, SIG2 >::Function chained(SIG1 &f1, SIG2 &f2)
build a functor chaining the given functions
Adapter container to take snapshots from non-assignable values.
MementoTie(function< SIG_undo > const &undoFunc, function< SIG_cap > const &captureFunc)
creates an execution context tying together the provided functions.
Metaprogramming helpers for deriving the precise function signatures necessary to implement a given c...
ReplaceableItem< MEM > memento_
storage holding the captured state for undo
MEM & getState()
access the currently captured memento state value
Adapter wrapper to treat non-assignable values as if they were assignable.
Binding together state capturing and execution of the undo operation.