Lumiera  0.pre.03
»edit your freedom«
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)
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 
22 #ifndef CONTROL_ARGUMENT_ERASURE_H
23 #define CONTROL_ARGUMENT_ERASURE_H
24 
25 #include "lib/error.hpp"
26 
27 
28 namespace lumiera {
29 namespace error {
30  LUMIERA_ERROR_DECLARE (INVALID_ARGUMENTS);
31  LUMIERA_ERROR_DECLARE (UNBOUND_ARGUMENTS);
32 }}
33 
34 namespace steam {
35 namespace control {
36  namespace err = lumiera::error;
37 
38 
49  struct Arguments;
50 
51  template<typename TUP>
53 
54 
55  struct Arguments
56  {
57  virtual ~Arguments() {}
58 
59  template<typename TUP>
60  TUP const&
61  get()
62  {
63  TypedArguments<TUP>* dest = dynamic_cast<TypedArguments<TUP>*> (this);
64  if (not dest)
65  throw err::Invalid{"Wrong type or number of arguments"
66  , LERR_(INVALID_ARGUMENTS)};
67  return dest->args_;
68  }
69  };
70 
71 
72  template<typename TUP>
73  struct TypedArguments
74  : Arguments
75  {
76  TUP const& args_;
77 
78  TypedArguments (TUP const& a)
79  : args_(a)
80  { }
81  };
82 
83 
84 
85 }} // namespace steam::control
86 #endif
#define LUMIERA_ERROR_DECLARE(err)
Forward declare an error constant.
Definition: error.h:62
Steam-Layer implementation namespace root.
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:190
Lumiera error handling (C++ interface).
Lumiera public interface.
Definition: advice.cpp:104