Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
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
28namespace lumiera {
29namespace error {
30 LUMIERA_ERROR_DECLARE (INVALID_ARGUMENTS);
31 LUMIERA_ERROR_DECLARE (UNBOUND_ARGUMENTS);
32}}
33
34namespace steam {
35namespace control {
36 namespace err = lumiera::error;
37
38
49 struct Arguments;
50
51 template<typename TUP>
52 struct TypedArguments;
53
54
55 struct Arguments
56 {
57 virtual ~Arguments() {}
58
59 template<typename TUP>
60 TUP const&
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>
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
Derived specific exceptions within Lumiera's exception hierarchy.
Definition error.hpp:193
#define LUMIERA_ERROR_DECLARE(err)
Forward declare an error constant.
Definition error.h:62
Lumiera error handling (C++ interface).
#define LERR_(_NAME_)
Definition error.hpp:45
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
Lumiera public interface.
Definition advice.hpp:102
Steam-Layer implementation namespace root.