17 #ifndef VCSN_ALGEBRA_CONCEPT_FREEMONOID_PRODUCT_HXX
18 # define VCSN_ALGEBRA_CONCEPT_FREEMONOID_PRODUCT_HXX
20 # include <vaucanson/algebra/concept/freemonoid_product.hh>
26 template <
typename F,
typename S>
27 MonoidRep<FreeMonoidProduct<F, S> >::MonoidRep() :
33 template <
typename Semiring,
typename F,
typename S>
35 SeriesRep<Semiring, FreeMonoidProduct<F, S> >::
36 disambiguate(
const monoid_t& monoid, pointer_t& p)
39 typedef boost::shared_ptr<first_rep_t> first_p_t;
40 typedef boost::shared_ptr<second_rep_t> second_p_t;
42 first_p_t first_rep(
new first_rep_t(p->first_representation()));
43 second_p_t second_rep(
new second_rep_t(p->second_representation()));
46 first_p_t first_rep_orig = first_rep;
47 second_p_t second_rep_orig = second_rep;
50 first_rep->disambiguate(monoid.first_monoid(), first_rep);
51 second_rep->disambiguate(monoid.second_monoid(), second_rep);
54 if (first_rep_orig != first_rep || second_rep_orig != second_rep)
57 new_rep.first_representation() = *first_rep;
58 new_rep.second_representation() = *second_rep;
59 p = pointer_t(
new self_t(new_rep));
63 template <
typename Semiring,
typename F,
typename S>
64 SeriesRep<Semiring, F>&
65 SeriesRep<Semiring, FreeMonoidProduct<F, S> >::first_representation()
67 return first_representation_;
70 template <
typename Semiring,
typename F,
typename S>
71 const SeriesRep<Semiring, F>&
72 SeriesRep<Semiring, FreeMonoidProduct<F, S> >::first_representation()
const
74 return first_representation_;
77 template <
typename Semiring,
typename F,
typename S>
78 SeriesRep<Semiring, S>&
79 SeriesRep<Semiring, FreeMonoidProduct<F, S> >::second_representation()
81 return second_representation_;
84 template <
typename Semiring,
typename F,
typename S>
85 const SeriesRep<Semiring, S>&
86 SeriesRep<Semiring, FreeMonoidProduct<F, S> >::second_representation()
const
88 return second_representation_;
91 template <
typename F,
typename S>
93 operator==(boost::shared_ptr<MonoidRep<FreeMonoidProduct<F, S> > > lhs,
94 boost::shared_ptr<MonoidRep<FreeMonoidProduct<F, S> > > rhs)
97 typedef MonoidRepBase<MonoidRep, FreeMonoidProduct<F, S> >
99 typedef boost::shared_ptr<monoid_rep_base_t> p_t;
101 return (lhs->open_par == rhs->open_par &&
102 lhs->sep == rhs->sep &&
103 lhs->close_par == rhs->close_par &&
104 static_cast<p_t>(lhs) == static_cast<p_t>(rhs));
107 template <
typename Semiring,
typename F,
typename S>
109 operator==(boost::shared_ptr<SeriesRep<Semiring, FreeMonoidProduct<F, S> > > lhs,
110 boost::shared_ptr<SeriesRep<Semiring, FreeMonoidProduct<F, S> > > rhs)
113 typedef SeriesRep<Semiring, F> first_rep_t;
114 typedef SeriesRep<Semiring, S> second_rep_t;
115 typedef SeriesRepBase<SeriesRep, Semiring, FreeMonoidProduct<F, S> >
119 typedef boost::shared_ptr<first_rep_t> first_p_t;
120 typedef boost::shared_ptr<second_rep_t> second_p_t;
121 typedef boost::shared_ptr<series_rep_base_t> p_t;
124 first_p_t lhs_first(
new first_rep_t());
125 second_p_t lhs_second(
new second_rep_t());
126 first_p_t rhs_first(
new first_rep_t());
127 second_p_t rhs_second(
new second_rep_t());
129 *lhs_first = lhs->first_representation();
130 *lhs_second = lhs->second_representation();
131 *rhs_first = rhs->first_representation();
132 *rhs_second = rhs->second_representation();
134 return (lhs_first == rhs_first &&
135 lhs_second == rhs_second &&
136 static_cast<p_t>(lhs) == static_cast<p_t>(rhs));
163 template <
typename F,
typename S>
165 split_monoid_(F&, S&)
168 template <
typename F>
170 split_monoid_(F& first_monoid, F& second_monoid)
172 if (first_monoid.representation().get() == second_monoid.representation().get())
174 typename F::monoid_rep_t second = *(second_monoid.representation());
175 second_monoid.set_representation(second);
179 template <
class F,
class S>
181 first_monoid_(a), second_monoid_(b),
184 split_monoid_(first_monoid_, second_monoid_);
187 template <
class F,
class S>
190 first_monoid_(a), second_monoid_(b),
193 split_monoid_(first_monoid_, second_monoid_);
196 template <
class F,
class S>
199 first_monoid_(w.first_monoid_),
200 second_monoid_(w.second_monoid_),
203 split_monoid_(first_monoid_, second_monoid_);
206 template <
class F,
class S>
210 return first_monoid_;
213 template <
class F,
class S>
217 return first_monoid_;
220 template <
class F,
class S>
224 return second_monoid_;
227 template <
class F,
class S>
231 return second_monoid_;
234 template <
typename F,
typename S>
235 const boost::shared_ptr<MonoidRep<FreeMonoidProduct<F, S> > >
241 template <
typename F,
typename S>
245 rep_ = boost::shared_ptr<MonoidRep<FreeMonoidProduct<F, S> > >(
new MonoidRep<FreeMonoidProduct<F, S> > (mr));
248 template <
typename F,
typename S>
262 #endif // ! VCSN_ALGEBRA_CONCEPT_FREEMONOID_PRODUCT_HXX