Lumiera  0.pre.03
»edit your freedom«
visitor-policies.hpp
Go to the documentation of this file.
1 /*
2  VISITOR-POLICIES.hpp - Acyclic Visitor library
3 
4  Copyright (C) Lumiera.org
5  2008, 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 
32 #ifndef LUMIERA_VISITOR_POLICIES_H
33 #define LUMIERA_VISITOR_POLICIES_H
34 
35 #include "lib/error.hpp"
36 
37 
38 namespace lib {
39 namespace visitor {
40 
46  template<class RET>
47  struct UseDefault
48  {
49  template<class TAR>
50  RET
51  onUnknown (TAR&)
52  {
53  return RET();
54  }
55  };
56 
60  template<class RET>
62  {
63  template<class TAR>
64  RET
65  onUnknown (TAR&)
66  {
67  throw lumiera::error::Config("unable to decide what tool operation to call");
68  }
69  };
70 
71 
72 
73 }} // namespace lib::visitor
74 #endif
Implementation namespace for support and library code.
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:199
Lumiera error handling (C++ interface).
Policy to throw when encountering an unknown visiting tool.
Policy returning just the default return value in case of encountering an unknown Visitor (typically ...