Vaucanson 1.4
|
00001 // fmp.hh: this file is part of the Vaucanson project. 00002 // 00003 // Vaucanson, a generic library for finite state machines. 00004 // 00005 // Copyright (C) 2007, 2008, 2010 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 00018 #ifndef VCSN_XML_CONTEXTS_FMP_HH 00019 # define VCSN_XML_CONTEXTS_FMP_HH 00020 00031 # include <string> 00032 00033 # include <xercesc/sax2/Attributes.hpp> 00034 # include <xercesc/util/XMLString.hpp> 00035 00036 # include <vaucanson/xml/handlers_base.hh> 00037 # include <vaucanson/xml/builders.hh> 00038 # include <vaucanson/xml/regexp.hh> 00039 00040 # include <vaucanson/automata/concept/automata.hh> 00041 # include <vaucanson/automata/concept/automata_kind.hh> 00042 # include <vaucanson/algebra/implementation/series/series.hh> 00043 # include <vaucanson/algebra/concept/freemonoid_product.hh> 00044 00045 # define FMPtype \ 00046 Element< \ 00047 Automata< \ 00048 vcsn::algebra::Series<S, vcsn::algebra::FreeMonoidProduct<M1, M2> >, \ 00049 labels_are_series \ 00050 >, \ 00051 T> 00052 # define TParamFMP template <class S, class T, class M1, class M2> 00053 # define FMPsreptype algebra::SeriesRep<S, algebra::FreeMonoidProduct<M1, M2> > 00054 00055 # define FMPseries Element<vcsn::algebra::Series<S, vcsn::algebra::FreeMonoidProduct<M1, M2> >, T> 00056 # define SParamFMP template <class S, class T, class M1, class M2> 00057 00058 00059 namespace vcsn 00060 { 00061 namespace xml 00062 { 00066 template <typename T> 00067 class FreeMonoidProductHandler : public Handler 00068 { 00069 public: 00070 FreeMonoidProductHandler (xercesc::SAX2XMLReader* parser, 00071 Handler& root, 00072 T& monoid); 00073 00074 void 00075 start (const XMLCh* const uri, 00076 const XMLCh* const localname, 00077 const XMLCh* const qname, 00078 const xercesc::Attributes& attrs); 00079 void 00080 end (const XMLCh* const uri, 00081 const XMLCh* const localname, 00082 const XMLCh* const qname); 00083 private: 00084 T& monoid_; 00085 Handler* monoidh_; 00086 UnsupHandler unsuph_; 00087 00088 bool first_; 00089 }; 00090 00094 template <typename S, typename M1, typename M2> 00095 class SeriesRepresentationHandler<FMPsreptype> : public Handler 00096 { 00097 public: 00098 // Type helpers. 00099 typedef FMPsreptype srep_t; 00100 00101 SeriesRepresentationHandler(xercesc::SAX2XMLReader* parser, 00102 Handler& root, 00103 srep_t& srep); 00104 00105 void start(const XMLCh* const uri, 00106 const XMLCh* const localname, 00107 const XMLCh* const qname, 00108 const xercesc::Attributes& attrs); 00109 00110 void end(const XMLCh* const uri, 00111 const XMLCh* const localname, 00112 const XMLCh* const qname); 00113 00114 private: 00115 srep_t& rep_; 00116 00117 Handler* reph_; 00118 UnsupHandler unsuph_; 00119 bool first_; 00120 }; 00121 00122 namespace builders 00123 { 00124 TParamFMP 00125 typename FMPtype::monoid_t* 00126 create_monoid (FMPtype& aut, 00127 const XMLCh* const localname, 00128 const xercesc::Attributes& attrs, 00129 XMLEq&); 00130 00131 template <typename M1, typename M2> 00132 Handler* 00133 create_monoidh (vcsn::algebra::FreeMonoidProduct<M1, M2>& monoid, 00134 const xercesc::Attributes& attrs, 00135 xercesc::SAX2XMLReader* parser, 00136 Handler& root); 00137 } // !builders 00138 00142 template <typename T> 00143 class ProdMonElmtHandler 00144 : public RegexpHandler<T> 00145 { 00146 // Access to base class protected members. 00147 using RegexpHandler<T>::eq_; 00148 using RegexpHandler<T>::parser_; 00149 using RegexpHandler<T>::end_; 00150 using RegexpHandler<T>::param_; 00151 using RegexpHandler<T>::root_; 00152 00153 public: 00154 ProdMonElmtHandler (xercesc::SAX2XMLReader* parser, 00155 Handler& root, 00156 T param); 00157 00158 void 00159 start (const XMLCh* const uri, 00160 const XMLCh* const localname, 00161 const XMLCh* const qname, 00162 const xercesc::Attributes& attrs); 00163 void 00164 end (const XMLCh* const uri, 00165 const XMLCh* const localname, 00166 const XMLCh* const qname); 00167 protected: 00168 int in_; 00169 int count_; 00170 00171 00172 typedef typename T::monoid_elt_t::first_monoid_t first_monoid_t; 00173 typedef typename T::monoid_elt_t::second_monoid_t second_monoid_t; 00174 typedef typename T::monoid_elt_t::first_monoid_elt_t first_monoid_elt_t; 00175 typedef typename T::monoid_elt_t::second_monoid_elt_t second_monoid_elt_t; 00176 first_monoid_elt_t m1_; 00177 second_monoid_elt_t m2_; 00178 }; 00179 00180 namespace builders 00181 { 00182 SParamFMP 00183 RegexpHandler<FMPseries >* 00184 create_monElmth(xercesc::SAX2XMLReader* parser, 00185 RegexpHandler<FMPseries >& root, 00186 FMPseries param); 00187 } // !builders 00188 00192 namespace builders 00193 { 00194 TParamFMP 00195 void 00196 check_monoid_consistency (FMPtype&, 00197 const XMLCh* const localname, 00198 const xercesc::Attributes& attrs, 00199 XMLEq&); 00200 } // !builders 00201 00205 namespace builders 00206 { 00207 TParamFMP 00208 void 00209 create_type_writingData_node(const FMPtype& aut, 00210 xercesc::DOMDocument* doc, 00211 xercesc::DOMElement* root); 00212 00213 TParamFMP 00214 void 00215 create_type_writingData_node(const FMPseries& aut, 00216 xercesc::DOMDocument* doc, 00217 xercesc::DOMElement* root); 00218 00219 TParamFMP 00220 void 00221 create_monoid_node(const FMPtype& aut, 00222 xercesc::DOMDocument* doc, 00223 xercesc::DOMElement* root); 00224 00225 TParamFMP 00226 void 00227 create_monoid_node(const FMPseries& aut, 00228 xercesc::DOMDocument* doc, 00229 xercesc::DOMElement* root); 00230 } // !builders 00231 } // !xml 00232 } // !vcsn 00233 00234 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB 00235 # include <vaucanson/xml/contexts/fmp.hxx> 00236 # endif // VCSN_USE_INTERFACE_ONLY || !VCSN_USE_LIB 00237 00238 # undef SParamFMP 00239 # undef FMPseries 00240 # undef TParamFMP 00241 # undef FMPtype 00242 00243 #endif // !VCSN_XML_CONTEXTS_FMP_HH