Salome HOME
BUG: Installation procedure: libyacsloader_echo.so library has to be installed in...
[modules/yacs.git] / src / yacsloader / containerParsers.cxx
1 // Copyright (C) 2006-2013  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.
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"
22
23 //#define _DEVDEBUG_
24 #include "YacsTrace.hxx"
25
26 namespace YACS
27 {
28   containertypeParser containertypeParser::containerParser;
29   machinetypeParser machinetypeParser::machineParser;
30   loadtypeParser loadtypeParser::loadParser;
31
32   void machinetypeParser::buildAttr(const XML_Char** attr)
33     {
34       required("name",attr);
35       for (int i = 0; attr[i]; i += 2)
36       {
37         if(std::string(attr[i]) == "name")name(attr[i+1]);
38       }
39     }
40   void machinetypeParser::pre (){_mach._name="";}
41   void machinetypeParser::name(const std::string& name){ _mach._name=name; }
42   machine machinetypeParser::post()
43     {
44       return _mach;
45     }
46
47   void containertypeParser::buildAttr(const XML_Char** attr)
48     {
49       required("name",attr);
50       for (int i = 0; attr[i]; i += 2)
51       {
52         if(std::string(attr[i]) == "name")name(attr[i+1]);
53       }
54     }
55   void containertypeParser::onStart(const XML_Char* el, const XML_Char** attr)
56     {
57       std::string element(el);
58       parser* pp=&parser::main_parser;
59       if(element == "machine")pp=&machinetypeParser::machineParser;
60       if(element == "property")pp=&propertytypeParser::propertyParser;
61       SetUserDataAndPush(pp);
62       pp->init();
63       pp->pre();
64       pp->buildAttr(attr);
65     }
66   void containertypeParser::onEnd(const char *el,parser* child)
67     {
68       std::string element(el);
69       if(element == "machine")machine_(((machinetypeParser*)child)->post());
70       if(element == "property")property(((propertytypeParser*)child)->post());
71     }
72   void containertypeParser::pre ()
73     {
74       _container._machs.clear();
75       _container._props.clear();
76     }
77   void containertypeParser::name(const std::string& name){ _container._name=name; }
78   void containertypeParser::machine_(const machine& m)
79     {
80       DEBTRACE( "machine: " << m._name )             
81       _container._machs.push_back(m);
82     }
83   void containertypeParser::property (const myprop& prop)
84     {
85       DEBTRACE( "property_set: " << prop._name << " " << prop._value );
86       _container._props[prop._name]=prop._value;
87     }
88   mycontainer containertypeParser::post()
89     {
90       //mincount("machine",1);
91       return _container;
92     }
93
94   void loadtypeParser::buildAttr(const XML_Char** attr)
95     {
96       required("container",attr);
97       for (int i = 0; attr[i]; i += 2)
98       {
99         if(std::string(attr[i]) == "container")container(attr[i+1]);
100       }
101     }
102   void loadtypeParser::pre (){_loadon._container="";}
103   void loadtypeParser::container(const std::string& name){ _loadon._container=name; }
104   loadon loadtypeParser::post()
105     {
106       return _loadon;
107     }
108
109 }