Vaucanson  1.4.1
exp.hh
1 // exp.hh: 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, 2006 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_RAT_EXP_HH
18 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_EXP_HH
19 
20 # include <vaucanson/algebra/implementation/series/rat/nodes.hh>
22 
23 namespace vcsn {
24 
25  namespace rat {
26 
28  template<typename LetterT, typename WeightT>
29  class exp
30  {
31  public:
32  typedef rat::Node<LetterT, WeightT> node_t;
33  typedef typename rat::Node<LetterT, WeightT>::type type;
34  typedef rat::Zero<LetterT, WeightT> n_zero_t;
35  typedef rat::One<LetterT, WeightT> n_one_t;
36  typedef rat::Sum<LetterT, WeightT> n_sum_t;
37  typedef rat::Product<LetterT, WeightT> n_prod_t;
38  typedef rat::Star<LetterT, WeightT> n_star_t;
39  typedef rat::Constant<LetterT, WeightT> n_const_t;
40 
41  public:
42  typedef LetterT monoid_elt_value_t;
43  typedef WeightT semiring_elt_value_t;
44 
46 
47  exp();
48  exp(node_t* p);
49  exp(const node_t* p);
50  exp(const exp& other);
52 
54  ~exp();
55 
57 
58  exp& operator = (const exp& other);
59  exp& operator += (const exp& other);
60  exp& operator *= (const exp& other);
62 
64  exp& star();
65 
67  exp& swap(exp& otether);
68 
70  void
71  accept(ConstNodeVisitor<monoid_elt_value_t, semiring_elt_value_t>& v)
72  const;
73 
75  size_t depth() const;
76 
85  size_t star_height() const;
86 
89  size_t length() const;
90 
92 
93  node_t* &base();
94  node_t* const &base() const;
96 
98 
99  bool operator == (const exp& other) const;
100  bool operator != (const exp& other) const;
101  bool operator < (const exp& other) const;
103 
105  exp clone() const;
106 
108 
109  static exp one();
110  static exp zero();
111  static exp constant(const monoid_elt_value_t& l);
113 
115  static bool starable();
116 
117  protected:
119  node_t *base_;
120  };
121 
122  template<typename M, typename W>
123  const exp<M, W> operator*(const exp<M, W>& lhs,
124  const exp<M, W>& rhs);
125 
126  template<typename M, typename W>
127  exp<M, W> operator+(const exp<M, W>& lhs,
128  const exp<M, W>& rhs);
129 
130  template<typename M, typename W>
131  exp<M, W> operator*(const W& lhs,
132  const exp<M, W>& rhs);
133 
134  template<typename M, typename W>
135  exp<M, W> operator*(const exp<M, W>& lhs,
136  const W& rhs);
137 
138  // FIXME: This is an *evil* hack, but without it there is an ambiguity
139  // FIXME: in calls to exp * number or number * exp.
140 
141  template<typename M, typename S, typename T>
143  operator*(const Element<S, T>& lhs,
144  const exp<M, Element<S, T> >& rhs);
145 
146  template<typename M, typename S, typename T>
148  operator*(const exp<M, Element<S, T> >& lhs,
149  const Element<S, T>& rhs);
150 
151  template<typename M, typename W>
152  void swap(vcsn::rat::exp<M, W>& lhs,
153  vcsn::rat::exp<M, W>& rhs);
154 
155  } // End of namespace rat.
156 
157 } // End of namespace vcsn.
158 
159 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
160 # include <vaucanson/algebra/implementation/series/rat/exp.hxx>
161 # endif // VCSN_USE_INTERFACE_ONLY
162 
163 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_EXP_HH