40 #ifndef CONTROL_COMMAND_IMPL_H 41 #define CONTROL_COMMAND_IMPL_H 85 HandlingPattern::ID defaultPatt_;
88 template<
typename ARG>
91 typedef typename ARG::SIG_op SIG_op;
92 typedef typename ARG::SIG_cap SIG_cap;
93 typedef typename ARG::SIG_undo SIG_undo;
95 typedef function<SIG_op> Func_op;
96 typedef function<SIG_cap> Func_cap;
97 typedef function<SIG_undo> Func_undo;
99 #define _TY(_ID_) typename _Type<ARG>::_ID_ 107 template<
typename ARG>
109 ,_TY (Func_op)
const& operFunctor
110 ,_TY (Func_cap)
const& captFunctor
111 ,_TY (Func_undo)
const& undoFunctor
114 , undo_(pStorageHolder->tie (undoFunctor, captFunctor))
115 , pClo_(pStorageHolder)
141 , defaultPatt_{orig.defaultPatt_}
145 explicit operator bool()
const {
return isValid(); }
167 pClo_->accept(visitor);
176 pClo_->bindArguments (args);
182 pClo_->bindArguments (paramData);
188 pClo_->unbindArguments();
191 void invokeOperation() { do_(*pClo_); }
192 void invokeCapture() { undo_.captureState(*pClo_); }
193 void invokeUndo() { undo_(*pClo_); }
197 typedef HandlingPattern::ID PattID;
200 getDefaultHandlingPattern()
const 210 PattID currID = defaultPatt_;
211 defaultPatt_ =
newID;
230 and pClo_->isValid();
236 return isValid() and pClo_->isCaptured();
239 operator string()
const 241 return _Fmt(
"Cmd|valid:%s, exec:%s, undo:%s |%s")
245 % (pClo_? string(*pClo_) : util::FAILURE_INDICATOR);
Core of a Steam-Layer command: functor containing the operation to be executed.
Any copy and copy construction prohibited.
bool canExec() const
< state check: sufficiently defined to be invoked
void prepareClone(CommandImplCloneBuilder &visitor) const
assist with building a clone copy of this CommandImpl.
bool isValid() const
< validity self-check: is basically usable.
PattID setHandlingPattern(PattID newID)
define a handling pattern to be used by default
Steam-Layer implementation namespace root.
A front-end for using printf-style formatting.
Specialised version of the command Mutation functor, used to implement the UNDO functionality.
Token or Atom with distinct identity.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Symbol cmdID
human-readable marker for diagnostics, will be (re)assigned when activating this CommandImpl ...
Steam-Layer command frontend.
Visitor to support creating a CommandImpl clone.
bool canUndo() const
< state check: has undo state been captured?
Unspecific command functor for implementing Steam-Layer Command.
A closure enabling self-contained execution of commands within the SteamDispatcher.
Steam-Layer Command implementation.
static HandlingPattern const & get(ID id)
retrieve the pre-configured pattern
CommandImpl(shared_ptr< ARG > pStorageHolder, _TY(Func_op) const &operFunctor, _TY(Func_cap) const &captFunctor, _TY(Func_undo) const &undoFunctor)
build a new implementation frame, and do the initial wiring.
object-like record of data.
CommandImpl(CommandImpl const &orig, UndoMutation const &newUndo, shared_ptr< CmdClosure > const &newClosure)
Interface: Operation Skeleton how to invoke or undo a command.
string newID(Symbol prefix)
create a random new ID