Vaucanson  1.4.1
rw.hh
Go to the documentation of this file.
1 // rw.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 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_RW_HH
19 # define VCSN_XML_CONTEXTS_RW_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>
40 
41 # include <vaucanson/automata/concept/transducer.hh>
42 # include <vaucanson/algebra/implementation/series/series.hh>
43 
44 # define TRANStype \
45  Element<Transducer<S, K>, T>
46 
47 # define TRANSseries \
48  Element<vcsn::algebra::Series<vcsn::algebra::Series<R, S>, T>, U>
49 
50 # define SParamTRANS \
51  template <typename R, typename S, typename T, typename U>
52 
53 # define TRANSsemiring \
54  vcsn::algebra::Series<S, T>
55 
56 namespace vcsn
57 {
58  namespace xml
59  {
63  template <typename T>
64  class SeriesSemiringHandler : public Handler
65  {
66  public:
67  SeriesSemiringHandler (xercesc::SAX2XMLReader* parser,
68  Handler& root,
69  T& semiring);
70 
71  void
72  start (const XMLCh* const uri,
73  const XMLCh* const localname,
74  const XMLCh* const qname,
75  const xercesc::Attributes& attrs);
76  void
77  end (const XMLCh* const uri,
78  const XMLCh* const localname,
79  const XMLCh* const qname);
80  private:
81  T& semiring_;
82  Handler* ssemiringh_;
83  Handler* monoidh_;
84  UnsupHandler unsuph_;
85  };
86 
87  SParamTRANS
88  class WeightHandler<TRANSseries > : public RegexpHandler<TRANSseries >
89  {
90  // Access to base class protected members.
96 
97  public:
98  WeightHandler (xercesc::SAX2XMLReader* parser,
99  Handler& root,
100  TRANSseries param);
101 
102  void
103  start (const XMLCh* const uri,
104  const XMLCh* const localname,
105  const XMLCh* const qname,
106  const xercesc::Attributes& attrs);
107  void
108  end (const XMLCh* const uri,
109  const XMLCh* const localname,
110  const XMLCh* const qname);
111 
112  protected:
113  typedef typename TRANSseries::set_t::semiring_t series_set_t;
114  typedef typename TRANSseries::value_t::semiring_elt_value_t series_set_elt_value_t;
116 
118  create_weighth(const XMLCh* const localname);
119 
121  };
122 
123  namespace builders
124  {
125  template <typename S, typename K, typename T>
126  typename TRANStype::semiring_t*
127  create_semiring (TRANStype&,
128  const XMLCh* const localname,
129  const xercesc::Attributes& attrs);
130 
131  template <typename S, typename T>
132  Handler*
133  create_semiringh(TRANSsemiring& semiring,
134  const xercesc::Attributes& attrs,
135  xercesc::SAX2XMLReader* parser,
136  Handler& root);
137 
138  } // !builders
139 
140  namespace builders
141  {
142  SParamTRANS
143  RegexpHandler<TRANSseries >*
144  create_weighth(xercesc::SAX2XMLReader* parser,
145  RegexpHandler<TRANSseries >& root,
146  TRANSseries param,
147  const xercesc::Attributes& attrs);
148  }
152  namespace builders
153  {
154  template <typename S, typename T>
155  const char* get_semiring_operations(const vcsn::algebra::Series<S, T>&);
156  } // !builders
157 
158  namespace builders
159  {
160  template <typename S, typename K, typename T>
161  void
162  create_semiring_node(const TRANStype&,
163  xercesc::DOMDocument* doc,
164  xercesc::DOMElement* root);
165  }
166  } // !xml
167 } // !vcsn
168 
169 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
170 # include <vaucanson/xml/contexts/rw.hxx>
171 # endif // VCSN_USE_INTERFACE_ONLY || !VCSN_USE_LIB
172 
173 # undef TRANStype
174 # undef TRANSseries
175 # undef SParamTRANS
176 # undef TRANSsemiring
177 
178 #endif // !VCSN_XML_CONTEXTS_RW_HH