00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_ALGEBRA_CONCEPT_FREEMONOID_PRODUCT_HXX
00018 # define VCSN_ALGEBRA_CONCEPT_FREEMONOID_PRODUCT_HXX
00019
00020 # include <vaucanson/algebra/concept/freemonoid_product.hh>
00021
00022 namespace vcsn
00023 {
00024 namespace algebra
00025 {
00026 template <typename F, typename S>
00027 monoid_rep<FreeMonoidProduct<F, S> >::monoid_rep() :
00028 monoid_rep<F>(),
00029 open_par("("),
00030 sep(","),
00031 close_par(")")
00032 {
00033 maybe_epsilon.clear();
00034
00035
00036 maybe_epsilon.push_back("1");
00037 maybe_epsilon.push_back("e");
00038
00039
00040 maybe_epsilon.push_back("_e");
00041 maybe_epsilon.push_back("eps");
00042
00043 empty = *(maybe_epsilon.begin());
00044 concat = "";
00045 }
00046
00047 template <typename F, typename S>
00048 monoid_rep<F>
00049 monoid_rep<FreeMonoidProduct<F, S> >::first_projection() const
00050 {
00051 monoid_rep<F> ret;
00052 ret.empty = empty;
00053 return ret;
00054 }
00055
00056 template <typename F, typename S>
00057 monoid_rep<S>
00058 monoid_rep<FreeMonoidProduct<F, S> >::second_projection() const
00059 {
00060 monoid_rep<S> ret;
00061 ret.empty = empty;
00062 return ret;
00063 }
00064
00065 template <typename Semiring, typename F, typename S>
00066 series_rep<Semiring, FreeMonoidProduct<F, S> >::series_rep() :
00067 series_rep<Semiring, F>()
00068 {
00069 }
00070
00071 template <typename Semiring, typename F, typename S>
00072 series_rep<Semiring, F>
00073 series_rep<Semiring, FreeMonoidProduct<F, S> >::first_projection() const
00074 {
00075 series_rep<Semiring, F> ret;
00076
00077 ret.open_par = open_par;
00078 ret.close_par = close_par;
00079 ret.plus = plus;
00080 ret.times = times;
00081 ret.star = star;
00082 ret.zero = zero;
00083 ret.open_weight = open_weight;
00084 ret.close_weight = close_weight;
00085 ret.spaces = spaces;
00086
00087 return ret;
00088 }
00089
00090 template <typename Semiring, typename F, typename S>
00091 series_rep<Semiring, S>
00092 series_rep<Semiring, FreeMonoidProduct<F, S> >::second_projection() const
00093 {
00094 series_rep<Semiring, S> ret;
00095
00096 ret.open_par = open_par;
00097 ret.close_par = close_par;
00098 ret.plus = plus;
00099 ret.times = times;
00100 ret.star = star;
00101 ret.zero = zero;
00102 ret.open_weight = open_weight;
00103 ret.close_weight = close_weight;
00104 ret.spaces = spaces;
00105
00106 return ret;
00107 }
00108
00109 template <typename F, typename S>
00110 bool
00111 operator==(boost::shared_ptr<monoid_rep<FreeMonoidProduct<F, S> > > lhs,
00112 boost::shared_ptr<monoid_rep<FreeMonoidProduct<F, S> > > rhs)
00113 {
00114 return (lhs->open_par == rhs->open_par) &&
00115 (lhs->sep == rhs->sep) &&
00116 (lhs->close_par == rhs->close_par) &&
00117 (static_cast<monoid_rep<F> >(lhs).representation() ==
00118 static_cast<monoid_rep<F> >(rhs).representation());
00119 }
00120
00121
00122
00123
00124
00125 template <class F, class S>
00126 FreeMonoidProduct<F, S>::FreeMonoidProduct(const F& a, const S& b) :
00127 first_monoid_ (a), second_monoid_ (b),
00128 rep_(monoid_rep_default<FreeMonoidProduct<F, S> >::get_instance())
00129 {}
00130
00131 template <class F, class S>
00132 FreeMonoidProduct<F, S>::FreeMonoidProduct(const F& a, const S& b,
00133 monoid_rep<FreeMonoidProduct<F, S> > mr) :
00134 first_monoid_ (a), second_monoid_ (b),
00135 rep_(boost::shared_ptr<monoid_rep<FreeMonoidProduct<F, S> > >(new monoid_rep<FreeMonoidProduct<F, S> >(mr)))
00136 {}
00137
00138 template <class F, class S>
00139 FreeMonoidProduct<F, S>::FreeMonoidProduct(const FreeMonoidProduct& w) :
00140 FreeMonoidProductBase<FreeMonoidProduct<F, S> >(w),
00141 first_monoid_(w.first_monoid_),
00142 second_monoid_(w.second_monoid_),
00143 rep_(w.rep_)
00144 {}
00145
00146 template <class F, class S>
00147 typename FreeMonoidProduct<F, S>::first_monoid_t&
00148 FreeMonoidProduct<F, S>::first_monoid()
00149 {
00150 return first_monoid_;
00151 }
00152
00153 template <class F, class S>
00154 const typename FreeMonoidProduct<F, S>::first_monoid_t&
00155 FreeMonoidProduct<F, S>::first_monoid() const
00156 {
00157 return first_monoid_;
00158 }
00159
00160 template <class F, class S>
00161 typename FreeMonoidProduct<F, S>::second_monoid_t&
00162 FreeMonoidProduct<F, S>::second_monoid()
00163 {
00164 return second_monoid_;
00165 }
00166
00167 template <class F, class S>
00168 const typename FreeMonoidProduct<F, S>::second_monoid_t&
00169 FreeMonoidProduct<F, S>::second_monoid() const
00170 {
00171 return second_monoid_;
00172 }
00173
00174 template <typename F, typename S>
00175 const boost::shared_ptr<monoid_rep<FreeMonoidProduct<F, S> > >
00176 FreeMonoidProduct<F, S>::representation() const
00177 {
00178 return rep_;
00179 }
00180
00181 template <typename F, typename S>
00182 void
00183 FreeMonoidProduct<F, S>::set_representation(monoid_rep<FreeMonoidProduct<F, S> > mr)
00184 {
00185 rep_ = boost::shared_ptr<monoid_rep<FreeMonoidProduct<F, S> > >(new monoid_rep<FreeMonoidProduct<F, S> > (mr));
00186 }
00187
00188 template<class F, class S>
00189 bool operator==(const FreeMonoidProduct<F, S>& a,
00190 const FreeMonoidProduct<F, S>& b)
00191 {
00192 return (a.first_monoid() == b.first_monoid()) and
00193 (a.second_monoid() == b.second_monoid());
00194 }
00195
00196 }
00197
00198 }
00199
00200 #endif // ! VCSN_ALGEBRA_CONCEPT_FREEMONOID_PRODUCT_HXX