Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
command-def.hpp
Go to the documentation of this file.
1/*
2 COMMAND-DEF.hpp - defining and binding a Steam-Layer 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
44#ifndef CONTROL_COMMAND_DEF_H
45#define CONTROL_COMMAND_DEF_H
46
47#include "lib/error.hpp"
48#include "lib/nocopy.hpp"
49#include "include/logging.h"
50#include "lib/symbol.hpp"
52#include "steam/control/command-impl.hpp" // note: at command definition site we need to know the full type
57#include "lib/meta/function.hpp"
58#include "lib/meta/typelist.hpp"
61#include "lib/util.hpp"
62
63#include <memory>
64#include <functional>
65
66
67
68
69namespace steam {
70namespace control {
71
72 using std::shared_ptr;
73 using std::function;
74 using std::bind;
75 using std::placeholders::_1;
76 using std::tuple_size;
77 using lib::Symbol;
78
79 using lib::meta::_Fun;
80 using lib::meta::Tuple;
81
82
83
84
85 namespace stage {
86
88 using Activation = function<Command&(ImplInstance &&)>;
89
90
91
92
93 template<typename SIG>
95 : AcceptArgumentBindingRet< Command&, SIG // Return type and Argument Signature of the \c bind(..) function
96 , CompletedDefinition<SIG> // target type (this class) providing the implementation \c bindArg(Tuple<..>)
97 >
98 {
100
102
110
111
113
118 {
120 return *this;
121 }
122
123
127 Command&
129 {
130 return prototype_.bindArg(params);
131 }
132
133
137 operator Command ()
138 {
139 return prototype_;
140 }
141
142 private:
147 void
149 {
150 if (0 == tuple_size<Tuple<CmdArgs>>::value )
151 prototype_.bindArg<> (std::tuple<>());
152 }
153 };
154
155
156
157
158
159 template<typename SIG, typename MEM>
203
204
205
206
209 template<typename U_SIG>
214
215
216
217
218
219
220 template<typename SIG>
244
245 } // (END) namespace stage (definition process)
246
247
267 {
270
273
274 public:
276 : id_(cmdID)
277 , prototype_(Command::fetchDef(cmdID))
278 {
279 TRACE (command_dbg, "starting CommandDef('%s')...", cmdID.c() );
280 }
281
282 ~CommandDef();
283
284
285
286 template<typename FUN>
287 auto
297
298
299 explicit operator bool() const { return isValid(); }
300
301 bool isValid() const;
302
303
304 private:
309 {
312 return prototype_;
313 }
314 };
315
316
317
318
319
320}} // namespace steam::control
321#endif
Mixin-templates providing arbitrary function call operators and argument binding functions.
constexpr const char * c() const
Definition symbol.hpp:93
Token or Atom with distinct identity.
Definition symbol.hpp:120
Variation of AcceptArgumentBinding, allowing to control the return type of the generated bind(....
Helper class used solely for defining a Command-Object.
stage::Activation Activation
stage::ImplInstance PImpl
auto operation(FUN operation_to_define)
bool isValid() const
is this a valid command definition? especially.
Definition command.cpp:340
Command & activate(PImpl &&completedDef)
callback from completed command definition stage: "arm up" the command handle object and register it ...
~CommandDef()
when starting a CommandDef, we immediately place a yet empty Command object into the index,...
Definition command.cpp:326
Registry managing command implementation objects (Singleton).
shared_ptr< CommandImpl > newCommandImpl(function< SIG_OPER > &operFunctor, function< SIG_CAPT > &captFunctor, function< SIG_UNDO > &undoFunctor)
set up a new command implementation frame
static lib::Depend< CommandRegistry > instance
storage for the singleton factory used to access CommandRegistry
Handle object representing a single Command instance to be used by client code.
Definition command.hpp:120
Command & bindArg(std::tuple< TYPES... > const &)
Definition command.hpp:243
HandlingPattern::ID setHandlingPattern(HandlingPattern::ID)
define a handling pattern to be used by default
Definition command.cpp:465
void activate(shared_ptr< CommandImpl > &&, Symbol cmdID=0)
Definition command.cpp:162
Case< Ret, Args >::CaptureSig CaptureSig
Any copy and copy construction prohibited.
Definition nocopy.hpp:38
Top level of the command implementation.
Core of a Steam-Layer command: functor containing the operation to be executed.
Managing command definitions and the storage of individual command objects.
Metaprogramming helpers for deriving the precise function signatures necessary to implement a given c...
Steam-Layer command frontend.
Lumiera error handling (C++ interface).
Metaprogramming tools for detecting and transforming function types.
This header is for including and configuring NoBug.
BuildTupleType< TYPES >::Type Tuple
Build a std::tuple from types given as type sequence.
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
Lumiera GTK UI implementation root.
Definition guifacade.cpp:37
shared_ptr< CommandImpl > ImplInstance
< helpers for building up a command definition
UndoDefinition< typename U_SIG::OperateSig, typename U_SIG::Memento > Type
function< Command &(ImplInstance &&)> Activation
type re-binding helper: create a suitable UndoDefinition type, based on the UndoSignature template in...
Steam-Layer implementation namespace root.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
#define Type(_EXPR_)
Trait template for uniform access to function signature types.
Definition function.hpp:144
auto captureUndo(FUN2 how_to_capture_UndoState)
BasicDefinition(Activation const &whenComplete, function< SIG > const &operation)
CompletedDefinition setHandlingPattern(PattID newID)
allow for defining the default execution pattern, which is used by Command::operator()
void maybeArm_if_zero_parameters()
Helper: automatically "bind" and make executable a command, for the case when the command operation t...
CompletedDefinition(Command &definedCommand)
Command & bindArg(Tuple< CmdArgs > const &params)
allow to bind immediately to a set of arguments.
function< UndoCaptureSig > CaptFunc
UndoDefinition(Activation const &whenComplete, OperFunc const &commandOperation, CaptFunc const &undoCapOperation)
function< UndoOperationSig > UndoFunc
CommandSignature< SIG, MEM > CmdType
CompletedDefinition< SIG > undoOperation(UndoOperationSig how_to_Undo)
function< CommandOperationSig > OperFunc
Marker types to indicate a literal string and a Symbol.
CStr cStr(std::string const &rendered)
convenience shortcut: forced conversion to c-String via string.
Definition symbol.hpp:60
Metaprogramming with tuples-of-types and the std::tuple record.
Metaprogramming: Helpers for manipulating lists-of-types.
A template metaprogramming technique for manipulating collections of types.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...