Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
command-mutation.hpp
Go to the documentation of this file.
1/*
2 COMMAND-MUTATION.hpp - functor encapsulating the actual operation of steam-Command
3
4 Copyright (C)
5 2009, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
14
36#ifndef CONTROL_COMMAND_MUTATION_H
37#define CONTROL_COMMAND_MUTATION_H
38
39#include "lib/error.hpp"
42
43
44
45namespace steam {
46namespace control {
47 namespace err = lumiera::error;
48
49
58 {
60
61 public:
62 template<typename SIG>
63 Mutation (function<SIG> const& func)
64 : func_(func)
65 { }
66
67
68
69 void
71 {
72 if (!clo)
73 throw err::State{"Lifecycle error: function arguments not ready"
74 , LERR_(UNBOUND_ARGUMENTS)};
75 clo.invoke (func_);
76 }
77 };
78
79
80
81
82
83
84
85
86
100 : public Mutation
101 {
103
104 public:
105 template<typename SIG, typename MEM>
107 : Mutation (mementoHolder.tieUndoFunc())
108 , captureMemento_(mementoHolder.tieCaptureFunc())
109 { }
110
111
112 Mutation&
114 {
115 if (!clo)
116 throw err::State{"need additional function arguments to be able to capture UNDO state"
117 , LERR_(UNBOUND_ARGUMENTS)};
118
120 return *this;
121 }
122
123
124 };
125
126
127}} // namespace steam::control
128#endif
Unspecific command functor for implementing Steam-Layer Command.
void operator()(CmdClosure &clo)
Mutation(function< SIG > const &func)
Specialised version of the command Mutation functor, used to implement the UNDO functionality.
UndoMutation(MementoTie< SIG, MEM > &mementoHolder)
Mutation & captureState(CmdClosure &clo)
A closure enabling self-contained execution of commands within the SteamDispatcher.
Lumiera error handling (C++ interface).
#define LERR_(_NAME_)
Definition error.hpp:45
A special binding used by Steam-Layer commands for capturing UNDO state information.
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
LumieraError< LERR_(STATE)> State
Definition error.hpp:209
Steam-Layer implementation namespace root.
Generic wrapper carrying a function object while hiding the actual function signature.