Version: 8.3.0
portParsers.hxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2016 CEA/DEN, EDF R&D
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 
28 namespace YACS
29 {
30 
47 template <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();
59 protected:
60  T _port;
61 };
62 
68 template <class T=myoutport>
70 {
72 };
73 
76 
77 template <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  }
88 template <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  }
94 template <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  }
107 template <class T>
109  {
110  _port._name="";
111  _port._type="";
112  _port.clear();
113  }
114 template <class T>
115  void inporttypeParser<T>::name(const std::string& name)
116  {
117  _port._name=name;
118  }
119 template <class T>
120  void inporttypeParser<T>::type(const std::string& type)
121  {
122  _port._type=type;
123  }
124 template <class T>
126  {
127  DEBTRACE( "property_set: " << prop._name << prop._value )
128  _port.setProperty(prop._name,prop._value);
129  }
130 template <class T>
132  {
133  return _port;
134  }
135 
136 }
137 
138 #endif