Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
argument-erasure.hpp
Go to the documentation of this file.
1 /*
2  ARGUMENT-ERASURE.hpp - helper for passing on a dynamic typed argument tuple
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 
31 #ifndef CONTROL_ARGUMENT_ERASURE_H
32 #define CONTROL_ARGUMENT_ERASURE_H
33 
34 #include "lib/error.hpp"
35 
36 
37 
38 namespace proc {
39 namespace control {
40 
41 
42  LUMIERA_ERROR_DECLARE (INVALID_ARGUMENTS);
43 
44 
45 
56  struct Arguments;
57 
58  template<typename TUP>
60 
61 
62  struct Arguments
63  {
64  virtual ~Arguments() {}
65 
66  template<typename TUP>
67  TUP const&
68  get ()
69  {
70  TypedArguments<TUP>* dest = dynamic_cast<TypedArguments<TUP>*> (this);
71  if (!dest)
72  throw lumiera::error::Invalid("Wrong type or number of arguments"
73  , LUMIERA_ERROR_INVALID_ARGUMENTS);
74 
75  return dest->args_;
76  }
77  };
78 
79 
80  template<typename TUP>
81  struct TypedArguments
82  : Arguments
83  {
84  TUP const& args_;
85 
86  TypedArguments (TUP const& a)
87  : args_(a)
88  { }
89  };
90 
91 
92 
93 
94 }} // namespace proc::control
95 #endif
LUMIERA_ERROR_DECLARE(INVALID_ARGUMENTS)
Arguments provided for binding doesn't match stored command function parameters.
LumieraError< LERR_(INVALID)> Invalid
Definition: error.hpp:216
Lumiera error handling (C++ interface).
Proc-Layer implementation namespace root.
Definition: id-scheme.hpp:63