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 <vaucanson/config/system.hh>
00021 
00022 # if (not defined (VCSN_SANITY_CHECK)) or (defined (VCSN_USE_XML))
00023 #  include <xercesc/dom/DOM.hpp>
00024 #  include <xercesc/util/XMLString.hpp>
00025 #  include <xercesc/util/PlatformUtils.hpp>
00026 # endif
00027 
00028 # include <vaucanson/algebra/implementation/series/rat/nodes.hh>
00029 # include <vaucanson/design_pattern/element.hh>
00030 
00031 namespace vcsn {
00032 
00033   namespace rat {
00034 
00036     template<typename LetterT, typename WeightT>
00037     class exp
00038     {
00039     public:
00040       typedef rat::Node<LetterT, WeightT>                       node_t;
00041       typedef typename rat::Node<LetterT, WeightT>::type        type;
00042       typedef rat::Zero<LetterT, WeightT>                       n_zero_t;
00043       typedef rat::One<LetterT, WeightT>                        n_one_t;
00044       typedef rat::Sum<LetterT, WeightT>                        n_sum_t;
00045       typedef rat::Product<LetterT, WeightT>                    n_prod_t;
00046       typedef rat::Star<LetterT, WeightT>                       n_star_t;
00047       typedef rat::Constant<LetterT, WeightT>                   n_const_t;
00048 
00049     public:
00050       typedef LetterT monoid_elt_value_t;
00051       typedef WeightT semiring_elt_value_t;
00052 
00054 
00055       exp();
00056       exp(node_t* p);
00057       exp(const node_t* p);
00058       exp(const exp& other);
00060 
00062       ~exp();
00063 
00065 
00066       exp& operator = (const exp& other);
00067       exp& operator += (const exp& other);
00068       exp& operator *= (const exp& other);
00070 
00072       exp& star();
00073 
00075       exp& swap(exp& otether);
00076 
00078       void
00079       accept(ConstNodeVisitor<monoid_elt_value_t, semiring_elt_value_t>& v)
00080         const;
00081 
00083       size_t depth() const;
00084 
00093       size_t star_height() const;
00094 
00097       size_t length() const;
00098 
00099 # if (not defined (VCSN_SANITY_CHECK)) or (defined (VCSN_USE_XML))
00100         xercesc::DOMElement* xml_tree(xercesc::DOMDocument* doc,
00101                                       char* node_name) const;
00102 # endif
00103 
00105 
00106       node_t*           &base();
00107       node_t* const     &base() const;
00109 
00111 
00112       bool operator == (const exp& other) const;
00113       bool operator != (const exp& other) const;
00114       bool operator < (const exp& other) const;
00116 
00118       exp clone() const;
00119 
00121 
00122       static exp one();
00123       static exp zero();
00124       static exp constant(const monoid_elt_value_t& l);
00126 
00128       static bool starable();
00129 
00130     protected:
00132       node_t *base_;
00133     };
00134 
00135     template<typename M, typename W>
00136     const exp<M, W> operator*(const exp<M, W>& lhs,
00137                               const exp<M, W>& rhs);
00138 
00139     template<typename M, typename W>
00140     exp<M, W> operator+(const exp<M, W>& lhs,
00141                         const exp<M, W>& rhs);
00142 
00143     template<typename M, typename W>
00144     exp<M, W> operator*(const W& lhs,
00145                         const exp<M, W>& rhs);
00146 
00147     template<typename M, typename W>
00148     exp<M, W> operator*(const exp<M, W>& lhs,
00149                         const W& rhs);
00150 
00151     // FIXME: This is an *evil* hack, but without it there is an ambiguity
00152     // FIXME: in calls to exp * number or number * exp.
00153 
00154     template<typename M, typename S, typename T>
00155     exp<M, Element<S, T> >
00156     operator*(const Element<S, T>& lhs,
00157               const exp<M, Element<S, T> >& rhs);
00158 
00159     template<typename M, typename S, typename T>
00160     exp<M, Element<S, T> >
00161     operator*(const exp<M, Element<S, T> >& lhs,
00162               const Element<S, T>& rhs);
00163 
00164     template<typename M, typename W>
00165     void swap(vcsn::rat::exp<M, W>& lhs,
00166               vcsn::rat::exp<M, W>& rhs);
00167 
00168   } // End of namespace rat.
00169 
00170 } // End of namespace vcsn.
00171 
00172 # ifndef VCSN_USE_INTERFACE_ONLY
00173 #  include <vaucanson/algebra/implementation/series/rat/exp.hxx>
00174 # endif // VCSN_USE_INTERFACE_ONLY
00175 
00176 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_EXP_HH

Generated on Fri Jul 28 12:18:31 2006 for Vaucanson by  doxygen 1.4.6