Vaucanson  1.4.1
krat_exp_is_finite_app.hxx
1 // krat_exp_is_finite_app.hxx: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2011 The Vaucanson Group.
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
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_SERIES_KRAT_EXP_IS_FINITE_APP_HXX
18 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_KRAT_EXP_IS_FINITE_APP_HXX
19 
20 # include <utility>
21 # include <vaucanson/algebra/implementation/series/krat_exp_pattern.hh>
22 
23 namespace vcsn {
24 
25  template <class Series, class T, class Dispatch>
26  class IsFiniteAppMatcher : public algebra::KRatExpMatcher<
27  IsFiniteAppMatcher<Series, T, Dispatch>,
28  T,
29  bool,
30  Dispatch
31  >
32  {
33  public:
34  typedef IsFiniteAppMatcher<Series, T, Dispatch> self_t;
35  typedef bool return_type;
36  INHERIT_CONSTRUCTORS(self_t, T, return_type, Dispatch);
37 
38  IsFiniteAppMatcher()
39  {}
40 
41  MATCH__(Product, lhs, rhs)
42  {
43  return this->match(lhs) && this->match(rhs);
44  }
45  END
46 
47  MATCH__(Sum, lhs, rhs)
48  {
49  return this->match(lhs) && this->match(rhs);
50  }
51  END
52 
53  MATCH_(Star, node)
54  {
55  return false;
56  }
57  END
58 
59  MATCH__(LeftWeight, w, node)
60  {
61  (void) w;
62  return this->match(node);
63  }
64  END
65 
66  MATCH__(RightWeight, node, w)
67  {
68  (void) w;
69  return this->match(node);
70  }
71  END
72 
73  MATCH_(Constant, m)
74  {
75  return true;
76  }
77  END
78 
79  MATCH(Zero)
80  {
81  return true;
82  }
83  END
84 
85  MATCH(One)
86  {
87  return true;
88  }
89  END
90 
91  };
92 
93 } // vcsn
94 
95 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_KRAT_EXP_IS_FINITE_APP_HXX