exp.hh

00001 // exp.hh: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 2001, 2002, 2003, 2004, 2006 The Vaucanson Group.
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // The complete GNU General Public Licence Notice can be found as the
00013 // `COPYING' file in the root directory.
00014 //
00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
00016 //
00017 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_EXP_HH
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_EXP_HH
00019 
00020 # include <xercesc/dom/DOM.hpp>
00021 # include <xercesc/util/XMLString.hpp>
00022 # include <xercesc/util/PlatformUtils.hpp>
00023 
00024 # include <vaucanson/algebra/implementation/series/rat/nodes.hh>
00025 # include <vaucanson/design_pattern/element.hh>
00026 
00027 namespace vcsn {
00028 
00029   namespace rat {
00030 
00032     template<typename LetterT, typename WeightT>
00033     class exp
00034     {
00035     public:
00036       typedef rat::Node<LetterT, WeightT>                       node_t;
00037       typedef typename rat::Node<LetterT, WeightT>::type        type;
00038       typedef rat::Zero<LetterT, WeightT>                       n_zero_t;
00039       typedef rat::One<LetterT, WeightT>                        n_one_t;
00040       typedef rat::Sum<LetterT, WeightT>                        n_sum_t;
00041       typedef rat::Product<LetterT, WeightT>                    n_prod_t;
00042       typedef rat::Star<LetterT, WeightT>                       n_star_t;
00043       typedef rat::Constant<LetterT, WeightT>                   n_const_t;
00044 
00045     public:
00046       typedef LetterT monoid_elt_value_t;
00047       typedef WeightT semiring_elt_value_t;
00048 
00050 
00051       exp();
00052       exp(node_t* p);
00053       exp(const node_t* p);
00054       exp(const exp& other);
00056 
00058       ~exp();
00059 
00061 
00062       exp& operator = (const exp& other);
00063       exp& operator += (const exp& other);
00064       exp& operator *= (const exp& other);
00066 
00068       exp& star();
00069 
00071       exp& swap(exp& otether);
00072 
00074       void
00075       accept(ConstNodeVisitor<monoid_elt_value_t, semiring_elt_value_t>& v)
00076         const;
00077 
00079       size_t depth() const;
00080 
00089       size_t star_height() const;
00090 
00093       size_t length() const;
00094 
00095         xercesc::DOMElement* xml_tree(xercesc::DOMDocument* doc,
00096                                       char* node_name) const;
00097 
00099 
00100       node_t*           &base();
00101       node_t* const     &base() const;
00103 
00105 
00106       bool operator == (const exp& other) const;
00107       bool operator != (const exp& other) const;
00108       bool operator < (const exp& other) const;
00110 
00112       exp clone() const;
00113 
00115 
00116       static exp one();
00117       static exp zero();
00118       static exp constant(const monoid_elt_value_t& l);
00120 
00122       static bool starable();
00123 
00124     protected:
00126       node_t *base_;
00127     };
00128 
00129     template<typename M, typename W>
00130     const exp<M, W> operator*(const exp<M, W>& lhs,
00131                               const exp<M, W>& rhs);
00132 
00133     template<typename M, typename W>
00134     exp<M, W> operator+(const exp<M, W>& lhs,
00135                         const exp<M, W>& rhs);
00136 
00137     template<typename M, typename W>
00138     exp<M, W> operator*(const W& lhs,
00139                         const exp<M, W>& rhs);
00140 
00141     template<typename M, typename W>
00142     exp<M, W> operator*(const exp<M, W>& lhs,
00143                         const W& rhs);
00144 
00145     // FIXME: This is an *evil* hack, but without it there is an ambiguity
00146     // FIXME: in calls to exp * number or number * exp.
00147 
00148     template<typename M, typename S, typename T>
00149     exp<M, Element<S, T> >
00150     operator*(const Element<S, T>& lhs,
00151               const exp<M, Element<S, T> >& rhs);
00152 
00153     template<typename M, typename S, typename T>
00154     exp<M, Element<S, T> >
00155     operator*(const exp<M, Element<S, T> >& lhs,
00156               const Element<S, T>& rhs);
00157 
00158     template<typename M, typename W>
00159     void swap(vcsn::rat::exp<M, W>& lhs,
00160               vcsn::rat::exp<M, W>& rhs);
00161 
00162   } // End of namespace rat.
00163 
00164 } // End of namespace vcsn.
00165 
00166 # ifndef VCSN_USE_INTERFACE_ONLY
00167 #  include <vaucanson/algebra/implementation/series/rat/exp.hxx>
00168 # endif // VCSN_USE_INTERFACE_ONLY
00169 
00170 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_EXP_HH

Generated on Sat Jul 29 17:12:59 2006 for Vaucanson by  doxygen 1.4.6