00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_ALGORITHMS_INTERNAL_PARTIAL_RAT_EXP_HH
00018 # define VCSN_ALGORITHMS_INTERNAL_PARTIAL_RAT_EXP_HH
00019
00032 # include <vaucanson/algebra/implementation/series/krat_exp_pattern.hh>
00033 # include <vaucanson/algorithms/krat_exp_constant_term.hh>
00034 # include <vaucanson/algebra/implementation/series/krat.hh>
00035 # include <list>
00036
00037 namespace vcsn
00038 {
00039
00040
00041
00042
00043 template <bool IsConst, typename T>
00044 struct reference_type
00045 { typedef T& ret; };
00046
00047 template <typename T>
00048 struct reference_type<true, T>
00049 { typedef const T& ret; };
00050
00051 template <bool IsConst, typename T>
00052 struct iterator_type
00053 { typedef typename T::iterator ret; };
00054
00055 template <typename T>
00056 struct iterator_type<true, T>
00057 { typedef typename T::const_iterator ret; };
00058
00059
00060
00061
00062
00063
00064 template <typename Series, typename T>
00065 struct PartialExp
00066 {
00067
00068 typedef Element<Series, T> exp_t;
00069 typedef Series series_set_t;
00070 typedef T series_set_elt_value_t;
00071 typedef typename T::node_t node_t;
00072 typedef typename exp_t::semiring_elt_t semiring_elt_t;
00073
00074
00075
00076
00077
00078 typedef std::list<const node_t*> node_list_t;
00079 typedef std::list<semiring_elt_t> semiring_elt_list_t;
00080
00081
00082
00083 PartialExp(const exp_t &e);
00084 PartialExp(const exp_t &e, const semiring_elt_t& w);
00085 PartialExp(const PartialExp &other);
00086
00087
00088 template <typename M, typename W>
00089 PartialExp& insert(const rat::Node<M, W>* v);
00090
00091
00092 semiring_elt_list_t& weights();
00093 const semiring_elt_list_t& weights() const;
00094 node_list_t& nodes();
00095 const node_list_t& nodes() const;
00096
00097
00098 PartialExp& operator<<=(const semiring_elt_t& w);
00099 PartialExp& operator>>=(const semiring_elt_t& w);
00100
00101
00102 const exp_t& exp() const;
00103 const Series& exp_structure() const;
00104 const T& exp_value() const;
00105
00106 protected:
00107
00108 const exp_t* rat_exp_;
00109 semiring_elt_list_t semiring_elt_list_;
00110 node_list_t node_list_;
00111
00112 public:
00113
00114 template <bool IsConst>
00115 struct internal_iterator
00116 {
00117 public:
00118 typedef typename
00119 reference_type<IsConst,semiring_elt_t>::ret semiring_elt_ref_t;
00120 typedef typename
00121 reference_type<IsConst,const node_t*>::ret node_ref_t;
00122 typedef typename
00123 iterator_type<IsConst,semiring_elt_list_t>::ret semiring_elts_iterator_t;
00124 typedef typename
00125 iterator_type<IsConst,node_list_t>::ret nodes_iterator_t;
00126 public:
00127 internal_iterator(const semiring_elts_iterator_t&,
00128 const nodes_iterator_t&);
00129 internal_iterator& operator++();
00130 internal_iterator operator++(int);
00131 bool operator!=(const internal_iterator& other);
00132 bool operator==(const internal_iterator& other);
00133 semiring_elt_ref_t semiring_elt() const;
00134 node_ref_t node() const;
00135 bool on_node() const;
00136 protected:
00137 semiring_elts_iterator_t semiring_elts_iterator_;
00138 nodes_iterator_t nodes_iterator_;
00139 bool on_node_;
00140 };
00141
00142
00143 typedef internal_iterator<false> iterator;
00144 typedef internal_iterator<true> const_iterator;
00145
00146
00147 iterator begin();
00148 iterator end();
00149 const_iterator begin() const;
00150 const_iterator end() const;
00151 };
00152
00153
00154
00155
00156
00157 template <typename S, typename T>
00158 std::ostream& operator<< (std::ostream& o, const PartialExp<S, T>& e);
00159
00160
00161 template <typename S, typename T>
00162 std::list<PartialExp<S, T> > prat_exp_convert(const std::list<Element<S, T> >& exp);
00163
00164 template <typename S, typename T>
00165 PartialExp<S, T> prat_exp_convert(const Element<S, T>& exp);
00166
00167 template <typename S, typename T>
00168 bool operator< (const PartialExp<S, T>& e1, const PartialExp<S, T>& e2);
00169
00170 template <typename S, typename T>
00171 bool operator== (const PartialExp<S, T>& e1, const PartialExp<S, T>& e2);
00172
00173 template <typename S, typename T>
00174 bool unweighted_eq(const PartialExp<S, T>& e1, const PartialExp<S, T>& e2);
00175
00176 template <typename S, typename T>
00177 bool unweighted_inf(const PartialExp<S, T>& e1, const PartialExp<S, T>& e2);
00178
00179 }
00180
00181
00182 # if !defined VCSN_USE_INTERFACE_ONLY && !defined VCSN_USE_LIB
00183 # include <vaucanson/algorithms/internal/partial_rat_exp.hxx>
00184 #endif // VCSN_USE_INTERFACE_ONLY
00185
00186
00187 #endif // ! VCSN_ALGORITHMS_INTERNAL_PARTIAL_RAT_EXP_HH