Lumiera  0.pre.03
»edityourfreedom«
command-closure.hpp File Reference

Go to the source code of this file.

Description

A closure enabling self-contained execution of commands within the ProcDispatcher.

After defining a proc-layer command, at some point the function arguments of the contained operation are "closed" by storing concrete argument values. These values will be fed later on to the operation when the command is invoked.

Most of the command machinery accesses this function closure through the generic interface CmdClosure, while, when defining a command, subclasses typed to the specific function arguments are created. Especially, there is an StorageHolder template, which is used to define the storage for the concrete arguments. This StorageHolder internally contains an OpClosure<SIG> instance (where SIG is the signature of the actual command operation function), which implements the invocation of the operation function with the stored argument tuple.

Command Closure and Lifecycle

When defining a command, Mutation objects are to be created based on a concrete function. These are stored embedded into a type erasure container, thus disposing the specific type information of the function and function arguments. Each command needs an Mutation object holding the command operation and an UndoMutation holding the undo functor.

Later on, any command needs to be made ready for execution by binding it to a specific execution environment, which especially includes the target objects to be mutated by the command. Effectively, this means "closing" the Mutation (and UNDO) functor(s)) with the actual function arguments. These arguments are stored embedded within an StorageHolder, which thereby acts as closure. Besides, the StorageHolder also has to accommodate for storage holding the captured UNDO state (memento). Internally the StorageHolder has to keep track of the actual types, thus allowing to re-construct the concrete function signature when closing the Mutation.

Finally, when invoking the command, it passes a CmdClosure& to the Mutation object, which allows the embedded function to be called with the concrete arguments. Besides just invoking it, a command can also be used like a prototype object. To support this use case it is possible to re-bind to a new set of command arguments, and to create a clone copy of the argument (holder) without disclosing the actual types involved.

See also
Command
ProcDispatcher
command-storage-holder.hpp
command-op-closure.hpp

Definition in file command-closure.hpp.

#include "lib/meta/function-erasure.hpp"
#include "proc/control/argument-erasure.hpp"
#include "lib/diff/gen-node.hpp"
#include <memory>
#include <string>

Classes

class  CmdClosure
 Interface. More...
 

Typedefs

typedef FunErasure< StoreFunction > CmdFunctor
 A neutral container internally holding the functor used to implement the Command. More...
 
using PClo = std::shared_ptr< CmdClosure >
 

Functions

 LUMIERA_ERROR_DECLARE (UNBOUND_ARGUMENTS)
 Command functor not yet usable, because arguments aren't bound. More...
 

Namespaces

 proc
 Proc-Layer implementation namespace root.
 
 proc::control
 Proc-Layer dispatcher, controller and administrative facilities.