Version: 9.16.0
portParsers.hxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
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, or (at your option) any later version.
7//
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.
12//
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
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef _PORTPARSERS_HXX_
21#define _PORTPARSERS_HXX_
22
23#include "parserBase.hxx"
24#include "propertyParsers.hxx"
25
26#include "factory.hxx"
27
28namespace YACS
29{
30
47template <class T=myinport>
49{
51 virtual void onStart(const XML_Char* el, const XML_Char** attr);
52 virtual void onEnd(const char *el,parser* child);
53 virtual void buildAttr(const XML_Char** attr);
54 virtual void pre ();
55 virtual void name(const std::string& name);
56 virtual void type(const std::string& type);
57 virtual void property (const myprop& prop);
58 virtual T& post();
59protected:
61};
62
68template <class T=myoutport>
70{
72};
73
76
77template <class T>
78 void inporttypeParser<T>::onStart(const XML_Char* el, const XML_Char** attr)
79 {
80 std::string element(el);
82 if(element == "property")pp=&propertytypeParser::propertyParser;
83 this->SetUserDataAndPush(pp);
84 pp->init();
85 pp->pre();
86 pp->buildAttr(attr);
87 }
88template <class T>
89 void inporttypeParser<T>::onEnd(const char *el,parser* child)
90 {
91 std::string element(el);
92 if(element == "property")property(((propertytypeParser*)child)->post());
93 }
94template <class T>
96 {
97 if (!attr)
98 return;
99 required("name",attr);
100 required("type",attr);
101 for (int i = 0; attr[i]; i += 2)
102 {
103 if(std::string(attr[i]) == "name")name(attr[i+1]);
104 if(std::string(attr[i]) == "type")type(attr[i+1]);
105 }
106 }
107template <class T>
109 {
110 _port._name="";
111 _port._type="";
112 _port.clear();
113 }
114template <class T>
115 void inporttypeParser<T>::name(const std::string& name)
116 {
117 _port._name=name;
118 }
119template <class T>
120 void inporttypeParser<T>::type(const std::string& type)
121 {
122 _port._type=type;
123 }
124template <class T>
126 {
127 DEBTRACE( "property_set: " << prop._name << prop._value )
128 _port.setProperty(prop._name,prop._value);
129 }
130template <class T>
132 {
133 return _port;
134 }
135
136}
137
138#endif
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
char XML_Char
Definition: parserBase.hxx:37
Class for Inport parser.
Definition: portParsers.hxx:49
virtual void name(const std::string &name)
virtual void type(const std::string &type)
virtual void property(const myprop &prop)
virtual void buildAttr(const XML_Char **attr)
Definition: portParsers.hxx:95
static inporttypeParser< T > inportParser
Definition: portParsers.hxx:50
virtual void onStart(const XML_Char *el, const XML_Char **attr)
Definition: portParsers.hxx:78
virtual void onEnd(const char *el, parser *child)
Definition: portParsers.hxx:89
Class for Outport parser.
Definition: portParsers.hxx:70
static outporttypeParser< T > outportParser
Definition: portParsers.hxx:71
virtual void init()
Definition: parserBase.cxx:86
virtual void pre()
Definition: parserBase.hxx:61
virtual void buildAttr(const XML_Char **attr)
Definition: parserBase.cxx:195
static parser main_parser
Definition: parserBase.hxx:41
Class for property parser.
static propertytypeParser propertyParser
std::string _name
Definition: factory.hxx:96
std::string _value
Definition: factory.hxx:97