Awali
Another Weighted Automata library
visitor.hh
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2022 Sylvain Lombardy, Victor Marsault, Jacques Sakarovitch
3 //
4 // Awali is a free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef AWALI_CORE_RAT_VISITOR_HH
18 # define AWALI_CORE_RAT_VISITOR_HH
19 
21 #include <awali/sttc/misc/raise.hh>
22 
23 namespace awali { namespace sttc
24 {
25  namespace rat
26  {
27 
28  template <typename Label, typename Weight>
30  {
31  public:
32  using label_t = Label;
33  using weight_t = Weight;
37  template <type_t Type>
39  template <type_t Type>
41  template <type_t Type>
43 
44  virtual ~const_visitor() = default;
45 
46 # define DEFINE(Type) \
47  using Type ## _t = Type<label_t, weight_t>; \
48  virtual void visit(const Type ## _t& v)
49 
63 # undef DEFINE
64  };
65 
66  } // namespace rat
67 }}//end of ns awali::stc
68 
69 # define AWALI_RAT_VISIT(Type, Val) \
70  using Type ## _t = typename super_type::Type ## _t; \
71  virtual void visit(const Type ## _t& Val) override
72 
73 # define AWALI_RAT_UNSUPPORTED(Type) \
74  AWALI_RAT_VISIT(Type,) \
75  { \
76  awali::sttc::raise(me(), ": " #Type " is not supported"); \
77  }
78 
80 
81 #endif // !AWALI_CORE_RAT_VISITOR_HH
Definition: ratexp.hh:280
Definition: visitor.hh:30
Label label_t
Definition: visitor.hh:32
Weight weight_t
Definition: visitor.hh:33
virtual ~const_visitor()=default
Definition: ratexp.hh:262
An inner node.
Definition: ratexp.hh:96
The root from which to derive the final node types.
Definition: ratexp.hh:248
The abstract parameterized, root for all rational expression types.
Definition: ratexp.hh:74
Definition: ratexp.hh:176
An inner node with multiple children.
Definition: ratexp.hh:115
An inner node implementing a weight.
Definition: ratexp.hh:208
Main namespace of Awali.
Definition: ato.hh:22
#define DEFINE(Type)
Definition: visitor.hh:46