1 // Copyright (C) 2006-2008 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef _LINKPARSERS_HXX_
20 #define _LINKPARSERS_HXX_
22 #include "parserBase.hxx"
23 #include "dataParsers.hxx"
24 #include "propertyParsers.hxx"
26 #include "factory.hxx"
30 template <class T=mycontrol>
31 struct controltypeParser: parser
33 static controltypeParser<T> controlParser;
35 virtual void onStart(const XML_Char* el, const XML_Char** attr)
37 std::string element(el);
38 parser* pp=&parser::main_parser;
39 this->maxcount("fromnode",1,element);
40 this->maxcount("tonode",1,element);
41 if(element == "fromnode")pp=&stringtypeParser::stringParser;
42 else if(element == "tonode")pp=&stringtypeParser::stringParser;
43 this->SetUserDataAndPush(pp);
48 virtual void onEnd(const char *el,parser* child)
50 std::string element(el);
51 if(element == "fromnode")fromnode(((stringtypeParser*)child)->post());
52 else if(element == "tonode")tonode(((stringtypeParser*)child)->post());
58 virtual void fromnode (const std::string& name)
62 virtual void tonode (const std::string& name)
66 virtual void property (const myprop& prop)
68 DEBTRACE( "property_set: " << prop._name << prop._value )
69 _link.setProperty(prop._name,prop._value);
73 mincount("fromnode",1);
80 template <class T=mylink>
81 struct linktypeParser: controltypeParser<T>
83 static linktypeParser<T> linkParser;
85 virtual void onStart(const XML_Char* el, const XML_Char** attr)
87 std::string element(el);
88 this->maxcount("fromnode",1,element);
89 this->maxcount("tonode",1,element);
90 this->maxcount("fromport",1,element);
91 this->maxcount("toport",1,element);
92 parser* pp=&parser::main_parser;
93 if(element == "fromnode")pp=&stringtypeParser::stringParser;
94 else if(element == "tonode")pp=&stringtypeParser::stringParser;
95 else if(element == "toport")pp=&stringtypeParser::stringParser;
96 else if(element == "fromport")pp=&stringtypeParser::stringParser;
97 else if(element == "property")pp=&propertytypeParser::propertyParser;
98 this->SetUserDataAndPush(pp);
103 virtual void onEnd(const char *el,parser* child)
105 std::string element(el);
106 if(element == "fromnode")this->fromnode(((stringtypeParser*)child)->post());
107 else if(element == "tonode")this->tonode(((stringtypeParser*)child)->post());
108 else if(element == "toport")toport(((stringtypeParser*)child)->post());
109 else if(element == "fromport")fromport(((stringtypeParser*)child)->post());
110 else if(element == "property")this->property(((propertytypeParser*)child)->post());
112 virtual void buildAttr(const XML_Char** attr)
114 for (int i = 0; attr[i]; i += 2)
116 if((std::string(attr[i]) == "control")
117 && (std::string(attr[i+1]) == "false"))
118 this->_link._withControl=false;
121 virtual void fromport (const std::string& name)
123 this->_link.fromport(name);
125 virtual void toport (const std::string& name)
127 this->_link.toport(name);
131 this->mincount("fromnode",1);
132 this->mincount("tonode",1);
133 this->mincount("fromport",1);
134 this->mincount("toport",1);
139 template <class T=mystream>
140 struct streamtypeParser: linktypeParser<T>
142 static streamtypeParser<T> streamParser;
145 template <class T> streamtypeParser<T> streamtypeParser<T>::streamParser;
146 template <class T> controltypeParser<T> controltypeParser<T>::controlParser;
147 template <class T> linktypeParser<T> linktypeParser<T>::linkParser;