]> SALOME platform Git repositories - modules/yacs.git/blob - src/yacsloader/containerParsers.cxx
Salome HOME
Merge branch 'agy/ParallelContainerLaunch'
[modules/yacs.git] / src / yacsloader / containerParsers.cxx
1 // Copyright (C) 2006-2014  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"
22 #include "HomogeneousPoolContainer.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
33   void machinetypeParser::buildAttr(const XML_Char** attr)
34     {
35       required("name",attr);
36       for (int i = 0; attr[i]; i += 2)
37       {
38         if(std::string(attr[i]) == "name")name(attr[i+1]);
39       }
40     }
41   void machinetypeParser::pre (){_mach._name="";}
42   void machinetypeParser::name(const std::string& name){ _mach._name=name; }
43   machine machinetypeParser::post()
44     {
45       return _mach;
46     }
47
48   void containertypeParser::buildAttr(const XML_Char** attr)
49     {
50       required("name",attr);
51       for (int i = 0; attr[i]; i += 2)
52       {
53         if(std::string(attr[i]) == "name")name(attr[i+1]);
54       }
55     }
56   void containertypeParser::onStart(const XML_Char* el, const XML_Char** attr)
57     {
58       std::string element(el);
59       parser* pp=&parser::main_parser;
60       if(element == "machine")pp=&machinetypeParser::machineParser;
61       if(element == "property")pp=&propertytypeParser::propertyParser;
62       if(element == "initializescriptkey")pp=&codetypeParser::codeParser;
63       SetUserDataAndPush(pp);
64       pp->init();
65       pp->pre();
66       pp->buildAttr(attr);
67     }
68   void containertypeParser::onEnd(const char *el,parser* child)
69     {
70       std::string element(el);
71       if(element == "machine")machine_(((machinetypeParser*)child)->post());
72       if(element == "property")property(((propertytypeParser*)child)->post());
73       if(element == "initializescriptkey")initializescriptkey(((codetypeParser*)child)->post());
74     }
75   void containertypeParser::pre ()
76     {
77       _container._machs.clear();
78       _container._props.clear();
79     }
80   void containertypeParser::name(const std::string& name){ _container._name=name; }
81   void containertypeParser::machine_(const machine& m)
82     {
83       DEBTRACE( "machine: " << m._name )             
84       _container._machs.push_back(m);
85     }
86   void containertypeParser::property (const myprop& prop)
87     {
88       DEBTRACE( "property_set: " << prop._name << " " << prop._value );
89       _container._props[prop._name]=prop._value;
90     }
91   void containertypeParser::initializescriptkey(const myfunc& f)
92   {
93     _container._props[YACS::ENGINE::HomogeneousPoolContainer::INITIALIZE_SCRIPT_KEY]=f._code;
94   }
95
96   mycontainer containertypeParser::post()
97     {
98       //mincount("machine",1);
99       return _container;
100     }
101
102   void loadtypeParser::buildAttr(const XML_Char** attr)
103     {
104       required("container",attr);
105       for (int i = 0; attr[i]; i += 2)
106       {
107         if(std::string(attr[i]) == "container")container(attr[i+1]);
108       }
109     }
110   void loadtypeParser::pre (){_loadon._container="";}
111   void loadtypeParser::container(const std::string& name){ _loadon._container=name; }
112   loadon loadtypeParser::post()
113     {
114       return _loadon;
115     }
116
117 }