Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
command-invocation.hpp
Go to the documentation of this file.
1 /*
2  COMMAND-INVOCATION.hpp - shortcuts and helpers for calling Proc-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 
49 #include "proc/control/command.hpp"
52 
53 #include <utility>
54 
55 
56 
57 namespace proc {
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  {
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  {
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
138  com::RuntimeCheckedCommandInvoker
139  invoke (Symbol cmdID)
140  {
141  Command command = Command::get (cmdID);
142  ASSERT (command);
143  return com::RuntimeCheckedCommandInvoker (command);
144  }
145 
146 
147  inline
148  com::RuntimeCheckedCommandInvoker
149  invoke (const char* cmdID)
150  {
151  return invoke(Symbol(cmdID));
152  }
153 
154 
155 }} // namespace proc::control
156 #endif
Mixin-templates providing arbitrary function call operators and argument binding functions.
Helper Template for building a Functor or function-like class: Mix in a function call operator...
typename BuildTupleType< TYPES >::Type Tuple
Build a std::tuple from types given as type sequence.
Command & bindArg(std::tuple< TYPES...> const &)
Definition: command.hpp:254
Token or Atom with distinct identity.
Definition: symbol.hpp:116
RET bind()
Accept dummy binding (0 Arg)
Proc-Layer command frontend.
static Command get(Symbol cmdID)
Access existing command for use.
Definition: command.cpp:127
Result (Status) of command execution.
Pre-defined command execution skeletons.
< Proc-Layer command implementation details
bool canExec() const
Definition: command.cpp:357
ExecResult bindArg(Tuple< TYPES > const &args)
com::RuntimeCheckedCommandInvoker invoke(Symbol cmdID)
Handle object representing a single Command instance to be used by client code.
Definition: command.hpp:125
Proc-Layer implementation namespace root.
Definition: id-scheme.hpp:63