Version: 8.3.0
containerParsers.cxx
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 #include "containerParsers.hxx"
21 #include "propertyParsers.hxx"
23 
24 //#define _DEVDEBUG_
25 #include "YacsTrace.hxx"
26 
27 namespace YACS
28 {
29  containertypeParser containertypeParser::containerParser;
30  machinetypeParser machinetypeParser::machineParser;
31  loadtypeParser loadtypeParser::loadParser;
32 
34  {
35  if (!attr)
36  return;
37  required("name",attr);
38  for (int i = 0; attr[i]; i += 2)
39  {
40  if(std::string(attr[i]) == "name")name(attr[i+1]);
41  }
42  }
44  void machinetypeParser::name(const std::string& name){ _mach._name=name; }
46  {
47  return _mach;
48  }
49 
51  {
52  if (!attr)
53  return;
54  required("name",attr);
55  for (int i = 0; attr[i]; i += 2)
56  {
57  if(std::string(attr[i]) == "name")name(attr[i+1]);
58  }
59  }
60  void containertypeParser::onStart(const XML_Char* el, const XML_Char** attr)
61  {
62  std::string element(el);
64  if(element == "machine")pp=&machinetypeParser::machineParser;
65  if(element == "property")pp=&propertytypeParser::propertyParser;
66  if(element == "initializescriptkey")pp=&codetypeParser::codeParser;
68  pp->init();
69  pp->pre();
70  pp->buildAttr(attr);
71  }
72  void containertypeParser::onEnd(const char *el,parser* child)
73  {
74  std::string element(el);
75  if(element == "machine")machine_(((machinetypeParser*)child)->post());
76  if(element == "property")property(((propertytypeParser*)child)->post());
77  if(element == "initializescriptkey")initializescriptkey(((codetypeParser*)child)->post());
78  }
80  {
81  _container._machs.clear();
82  _container._props.clear();
83  }
84  void containertypeParser::name(const std::string& name){ _container._name=name; }
86  {
87  DEBTRACE( "machine: " << m._name )
88  _container._machs.push_back(m);
89  }
91  {
92  DEBTRACE( "property_set: " << prop._name << " " << prop._value );
93  _container._props[prop._name]=prop._value;
94  }
96  {
98  }
99 
101  {
102  //mincount("machine",1);
103  return _container;
104  }
105 
107  {
108  if (!attr)
109  return;
110  required("container",attr);
111  for (int i = 0; attr[i]; i += 2)
112  {
113  if(std::string(attr[i]) == "container")container(attr[i+1]);
114  }
115  }
117  void loadtypeParser::container(const std::string& name){ _loadon._container=name; }
119  {
120  return _loadon;
121  }
122 
123 }