Lumiera  0.pre.03
»edit your freedom«
command-invocation.hpp
Go to the documentation of this file.
1 /*
2  COMMAND-INVOCATION.hpp - shortcuts and helpers for calling Steam-Layer commands
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 
37 #ifndef CONTROL_COMMAND_INVOCACTION_H
38 #define CONTROL_COMMAND_INVOCACTION_H
39 
43 
44 #include <utility>
45 
46 
47 
48 namespace steam {
49 namespace control {
50 
51  using namespace lib::meta;
52 
53 
54 
55  namespace com {
56  // define transient invoker objects, to allow for arbitrary bindings
57 
58  template<typename SIG>
60  {
61  typedef ExecResult SIG_Bind(int);
62  };
63 
64 
70  template<typename SIG>
72  : AcceptArgumentTuple< typename _DefineBindFunc<SIG>::SIG_Bind
73  , CommandInvoker<SIG>
74  >
75  {
76  Command com_;
77 
79  : com_(c)
80  { }
81 
82 
83  template<typename TYPES>
85  bindArg (Tuple<TYPES> const& args)
86  {
87  com_.bindArg(args);
88  ASSERT (com_.canExec());
89  return com_();
90  }
91  };
92 
93 
94 
105  {
106  Command com_;
107 
109  : com_(c)
110  { }
111 
112 
116  template<typename...ARGS>
117  ExecResult
118  operator() (ARGS&& ...args)
119  {
120  com_.bind (std::forward<ARGS> (args)...);
121  return com_();
122  }
123  };
124  }
125 
126 
127 
128  inline
130  invoke (Symbol cmdID)
131  {
132  Command command = Command::get (cmdID);
133  ASSERT (command);
134  return com::RuntimeCheckedCommandInvoker (command);
135  }
136 
137 
138  inline
140  invoke (const char* cmdID)
141  {
142  return invoke(Symbol(cmdID));
143  }
144 
145 
146 }} // namespace steam::control
147 #endif
< Steam-Layer command implementation details
typename BuildTupleType< TYPES >::Type Tuple
Build a std::tuple from types given as type sequence.
Helper Template for building a Functor or function-like class: Mix in a function call operator...
Mixin-templates providing arbitrary function call operators and argument binding functions.
static Command get(Symbol cmdID)
Access existing command for use.
Definition: command.cpp:120
Steam-Layer implementation namespace root.
Token or Atom with distinct identity.
Definition: symbol.hpp:117
Result (Status) of command execution.
Steam-Layer command frontend.
Pre-defined command execution skeletons.
Handle object representing a single Command instance to be used by client code.
Definition: command.hpp:115
RET bind()
Accept dummy binding (0 Arg)