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) Lumiera.org
5  2009, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
46 #ifndef CONTROL_COMMAND_INVOCACTION_H
47 #define CONTROL_COMMAND_INVOCACTION_H
48 
52 
53 #include <utility>
54 
55 
56 
57 namespace steam {
58 namespace control {
59 
60  using namespace lib::meta;
61 
62 
63 
64  namespace com {
65  // define transient invoker objects, to allow for arbitrary bindings
66 
67  template<typename SIG>
69  {
70  typedef ExecResult SIG_Bind(int);
71  };
72 
73 
79  template<typename SIG>
81  : AcceptArgumentTuple< typename _DefineBindFunc<SIG>::SIG_Bind
82  , CommandInvoker<SIG>
83  >
84  {
85  Command com_;
86 
88  : com_(c)
89  { }
90 
91 
92  template<typename TYPES>
94  bindArg (Tuple<TYPES> const& args)
95  {
96  com_.bindArg(args);
97  ASSERT (com_.canExec());
98  return com_();
99  }
100  };
101 
102 
103 
114  {
115  Command com_;
116 
118  : com_(c)
119  { }
120 
121 
125  template<typename...ARGS>
126  ExecResult
127  operator() (ARGS&& ...args)
128  {
129  com_.bind (std::forward<ARGS> (args)...);
130  return com_();
131  }
132  };
133  }
134 
135 
136 
137  inline
139  invoke (Symbol cmdID)
140  {
141  Command command = Command::get (cmdID);
142  ASSERT (command);
143  return com::RuntimeCheckedCommandInvoker (command);
144  }
145 
146 
147  inline
149  invoke (const char* cmdID)
150  {
151  return invoke(Symbol(cmdID));
152  }
153 
154 
155 }} // namespace steam::control
156 #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:129
Steam-Layer implementation namespace root.
Token or Atom with distinct identity.
Definition: symbol.hpp:126
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:124
RET bind()
Accept dummy binding (0 Arg)