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     PartialExp&                         insert(const node_t *v);
00089 
00090     
00091     semiring_elt_list_t&                weights();
00092     const semiring_elt_list_t&          weights() const;
00093     node_list_t&                        nodes();
00094     const node_list_t&                  nodes() const;
00095 
00096     
00097     PartialExp&                         operator<<=(const semiring_elt_t& w);
00098     PartialExp&                         operator>>=(const semiring_elt_t& w);
00099 
00100     
00101     const exp_t&                        exp() const;
00102     const Series&                       exp_structure() const;
00103     const T&                            exp_value() const;
00104 
00105   protected:
00106     
00107     const exp_t*                        rat_exp_;
00108     semiring_elt_list_t                 semiring_elt_list_;
00109     node_list_t                         node_list_;
00110 
00111   public:
00112     
00113     template <bool IsConst>
00114     struct internal_iterator
00115     {
00116     public:
00117       typedef typename
00118       reference_type<IsConst,semiring_elt_t>::ret       semiring_elt_ref_t;
00119       typedef typename
00120       reference_type<IsConst,const node_t*>::ret        node_ref_t;
00121       typedef typename
00122       iterator_type<IsConst,semiring_elt_list_t>::ret   semiring_elts_iterator_t;
00123       typedef typename
00124       iterator_type<IsConst,node_list_t>::ret           nodes_iterator_t;
00125     public:
00126       internal_iterator(const semiring_elts_iterator_t&,
00127                         const nodes_iterator_t&);
00128       internal_iterator&        operator++();
00129       internal_iterator         operator++(int);
00130       bool                      operator!=(const internal_iterator& other);
00131       bool                      operator==(const internal_iterator& other);
00132       semiring_elt_ref_t        semiring_elt() const;
00133       node_ref_t                node() const;
00134       bool                      on_node() const;
00135     protected:
00136       semiring_elts_iterator_t  semiring_elts_iterator_;
00137       nodes_iterator_t          nodes_iterator_;
00138       bool                      on_node_;
00139     };
00140 
00141     
00142     typedef internal_iterator<false>    iterator;
00143     typedef internal_iterator<true>     const_iterator;
00144 
00145     
00146     iterator                            begin();
00147     iterator                            end();
00148     const_iterator                      begin() const;
00149     const_iterator                      end() const;
00150   };
00151 
00152   
00153 
00154 
00155 
00156   template <typename S, typename T>
00157   std::ostream& operator<< (std::ostream& o, const PartialExp<S, T>& e);
00158 
00159   
00160   template <typename S, typename T>
00161   std::list<PartialExp<S, T> > prat_exp_convert(const std::list<Element<S, T> >& exp);
00162 
00163   template <typename S, typename T>
00164   PartialExp<S, T> prat_exp_convert(const Element<S, T>& exp);
00165 
00166   template <typename S, typename T>
00167   bool operator< (const PartialExp<S, T>& e1, const PartialExp<S, T>& e2);
00168 
00169   template <typename S, typename T>
00170   bool operator== (const PartialExp<S, T>& e1, const PartialExp<S, T>& e2);
00171 
00172   template <typename S, typename T>
00173   bool unweighted_eq(const PartialExp<S, T>& e1, const PartialExp<S, T>& e2);
00174 
00175   template <typename S, typename T>
00176   bool unweighted_inf(const PartialExp<S, T>& e1, const PartialExp<S, T>& e2);
00177 
00178 } 
00179 
00180 
00181 #ifndef VCSN_USE_INTERFACE_ONLY
00182 # include <vaucanson/algorithms/internal/partial_rat_exp.hxx>
00183 #endif // VCSN_USE_INTERFACE_ONLY
00184 
00185 
00186 #endif // ! VCSN_ALGORITHMS_INTERNAL_PARTIAL_RAT_EXP_HH