1 // Copyright (C) 2006-2015 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef _NODEPARSERS_HXX_
21 #define _NODEPARSERS_HXX_
23 #include "parserBase.hxx"
24 #include "containerParsers.hxx"
25 #include "dataParsers.hxx"
26 #include "portParsers.hxx"
27 #include "codeParsers.hxx"
28 #include "propertyParsers.hxx"
31 #include "TypeCode.hxx"
32 #include "InlineNode.hxx"
33 #include "Exception.hxx"
34 #include "Runtime.hxx"
35 #include "Container.hxx"
36 #include "ComponentInstance.hxx"
37 #include "OutputDataStreamPort.hxx"
38 #include "InputDataStreamPort.hxx"
39 #include "ComponentInstance.hxx"
40 #include "factory.hxx"
42 extern YACS::ENGINE::Proc* currentProc;
43 extern YACS::ENGINE::Runtime* theRuntime;
48 /*! \brief Class for node parser.
50 * This class is a base class for other parsers
52 template <class T=YACS::ENGINE::InlineNode*>
53 struct nodetypeParser: parser
55 static nodetypeParser<T> nodeParser;
57 virtual void onStart(const XML_Char* el, const XML_Char** attr)
59 DEBTRACE( "nodetypeParser::onStart: " << el )
60 std::string element(el);
61 parser* pp=&parser::main_parser;
62 this->SetUserDataAndPush(pp);
67 virtual void onEnd(const char *el,parser* child)
69 DEBTRACE( "nodetypeParser::onEnd: " << el )
70 std::string element(el);
72 virtual void buildAttr(const XML_Char** attr)
76 required("name",attr);
77 required("type",attr);
78 for (int i = 0; attr[i]; i += 2)
80 if(std::string(attr[i]) == "name")name(attr[i+1]);
81 if(std::string(attr[i]) == "state")state(attr[i+1]);
82 if(std::string(attr[i]) == "type")type(attr[i+1]);
90 virtual void name (const std::string& name)
92 DEBTRACE( "inline_name: " << name )
95 virtual void state (const std::string& name)
99 virtual void type (const std::string& name)
101 DEBTRACE( "node_type " << name )
104 virtual void property (const myprop& prop);
109 std::string _container;
113 template <class T> nodetypeParser<T> nodetypeParser<T>::nodeParser;
116 void nodetypeParser<T>::property (const myprop& prop)
119 throw YACS::Exception("Node must be completely defined before setting its properties");
120 _node->setProperty(prop._name,prop._value);
124 T nodetypeParser<T>::post()
130 YACS::ENGINE::InlineNode* nodetypeParser<YACS::ENGINE::InlineNode*>::post ()
132 std::string fullname = currentProc->names.back()+_type;
133 if(currentProc->inlineMap.count(_type) != 0)
135 //InlineNode type with absolute name found
136 YACS::ENGINE::InlineNode* n=currentProc->inlineMap[_type];
137 _node=n->cloneNode(_name);
139 else if(currentProc->inlineMap.count(fullname) != 0)
141 //InlineNode type with relative name found
142 YACS::ENGINE::InlineNode* n=currentProc->inlineMap[fullname];
143 _node=n->cloneNode(_name);
147 throw YACS::Exception("Unknown InlineNode type");
149 if(_state == "disabled")_node->exDisabledState();
150 DEBTRACE( "node_post " << _node->getName() )
154 } // end of namespace YACS