Vaucanson  1.4.1
fmp.hh
Go to the documentation of this file.
1 // fmp.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2007, 2008, 2010 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 
18 #ifndef VCSN_XML_CONTEXTS_FMP_HH
19 # define VCSN_XML_CONTEXTS_FMP_HH
20 
31 # include <string>
32 
33 # include <xercesc/sax2/Attributes.hpp>
34 # include <xercesc/util/XMLString.hpp>
35 
36 # include <vaucanson/xml/handlers_base.hh>
37 # include <vaucanson/xml/builders.hh>
38 # include <vaucanson/xml/regexp.hh>
39 
40 # include <vaucanson/automata/concept/automata.hh>
41 # include <vaucanson/automata/concept/automata_kind.hh>
42 # include <vaucanson/algebra/implementation/series/series.hh>
43 # include <vaucanson/algebra/concept/freemonoid_product.hh>
44 
45 # define FMPtype \
46  Element< \
47  Automata< \
48  vcsn::algebra::Series<S, vcsn::algebra::FreeMonoidProduct<M1, M2> >, \
49  labels_are_series \
50  >, \
51  T>
52 # define TParamFMP template <class S, class T, class M1, class M2>
53 # define FMPsreptype algebra::SeriesRep<S, algebra::FreeMonoidProduct<M1, M2> >
54 
55 # define FMPseries Element<vcsn::algebra::Series<S, vcsn::algebra::FreeMonoidProduct<M1, M2> >, T>
56 # define SParamFMP template <class S, class T, class M1, class M2>
57 
58 
59 namespace vcsn
60 {
61  namespace xml
62  {
66  template <typename T>
67  class FreeMonoidProductHandler : public Handler
68  {
69  public:
70  FreeMonoidProductHandler (xercesc::SAX2XMLReader* parser,
71  Handler& root,
72  T& monoid);
73 
74  void
75  start (const XMLCh* const uri,
76  const XMLCh* const localname,
77  const XMLCh* const qname,
78  const xercesc::Attributes& attrs);
79  void
80  end (const XMLCh* const uri,
81  const XMLCh* const localname,
82  const XMLCh* const qname);
83  private:
84  T& monoid_;
85  Handler* monoidh_;
86  UnsupHandler unsuph_;
87 
88  bool first_;
89  };
90 
94  template <typename S, typename M1, typename M2>
95  class SeriesRepresentationHandler<FMPsreptype> : public Handler
96  {
97  public:
98  // Type helpers.
99  typedef FMPsreptype srep_t;
100 
101  SeriesRepresentationHandler(xercesc::SAX2XMLReader* parser,
102  Handler& root,
103  srep_t& srep);
104 
105  void start(const XMLCh* const uri,
106  const XMLCh* const localname,
107  const XMLCh* const qname,
108  const xercesc::Attributes& attrs);
109 
110  void end(const XMLCh* const uri,
111  const XMLCh* const localname,
112  const XMLCh* const qname);
113 
114  private:
115  srep_t& rep_;
116 
117  Handler* reph_;
118  UnsupHandler unsuph_;
119  bool first_;
120  };
121 
122  namespace builders
123  {
124  TParamFMP
125  typename FMPtype::monoid_t*
126  create_monoid (FMPtype& aut,
127  const XMLCh* const localname,
128  const xercesc::Attributes& attrs,
129  XMLEq&);
130 
131  template <typename M1, typename M2>
132  Handler*
133  create_monoidh (vcsn::algebra::FreeMonoidProduct<M1, M2>& monoid,
134  const xercesc::Attributes& attrs,
135  xercesc::SAX2XMLReader* parser,
136  Handler& root);
137  } // !builders
138 
142  template <typename T>
144  : public RegexpHandler<T>
145  {
146  // Access to base class protected members.
147  using RegexpHandler<T>::eq_;
152 
153  public:
154  ProdMonElmtHandler (xercesc::SAX2XMLReader* parser,
155  Handler& root,
156  T param);
157 
158  void
159  start (const XMLCh* const uri,
160  const XMLCh* const localname,
161  const XMLCh* const qname,
162  const xercesc::Attributes& attrs);
163  void
164  end (const XMLCh* const uri,
165  const XMLCh* const localname,
166  const XMLCh* const qname);
167  protected:
168  int in_;
169  int count_;
170 
171 
172  typedef typename T::monoid_elt_t::first_monoid_t first_monoid_t;
173  typedef typename T::monoid_elt_t::second_monoid_t second_monoid_t;
174  typedef typename T::monoid_elt_t::first_monoid_elt_t first_monoid_elt_t;
175  typedef typename T::monoid_elt_t::second_monoid_elt_t second_monoid_elt_t;
176  first_monoid_elt_t m1_;
177  second_monoid_elt_t m2_;
178  };
179 
180  namespace builders
181  {
182  SParamFMP
184  create_monElmth(xercesc::SAX2XMLReader* parser,
186  FMPseries param);
187  } // !builders
188 
192  namespace builders
193  {
194  TParamFMP
195  void
196  check_monoid_consistency (FMPtype&,
197  const XMLCh* const localname,
198  const xercesc::Attributes& attrs,
199  XMLEq&);
200  } // !builders
201 
205  namespace builders
206  {
207  TParamFMP
208  void
209  create_type_writingData_node(const FMPtype& aut,
210  xercesc::DOMDocument* doc,
211  xercesc::DOMElement* root);
212 
213  TParamFMP
214  void
215  create_type_writingData_node(const FMPseries& aut,
216  xercesc::DOMDocument* doc,
217  xercesc::DOMElement* root);
218 
219  TParamFMP
220  void
221  create_monoid_node(const FMPtype& aut,
222  xercesc::DOMDocument* doc,
223  xercesc::DOMElement* root);
224 
225  TParamFMP
226  void
227  create_monoid_node(const FMPseries& aut,
228  xercesc::DOMDocument* doc,
229  xercesc::DOMElement* root);
230  } // !builders
231  } // !xml
232 } // !vcsn
233 
234 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
235 # include <vaucanson/xml/contexts/fmp.hxx>
236 # endif // VCSN_USE_INTERFACE_ONLY || !VCSN_USE_LIB
237 
238 # undef SParamFMP
239 # undef FMPseries
240 # undef TParamFMP
241 # undef FMPtype
242 
243 #endif // !VCSN_XML_CONTEXTS_FMP_HH