Version: 9.16.0
nodeParsers.hxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
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 _NODEPARSERS_HXX_
21#define _NODEPARSERS_HXX_
22
23#include "parserBase.hxx"
24#include "containerParsers.hxx"
25#include "dataParsers.hxx"
26#include "portParsers.hxx"
27#include "codeParsers.hxx"
28#include "propertyParsers.hxx"
29
30#include "Proc.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"
39#include "ComponentInstance.hxx"
40#include "factory.hxx"
41
44
45namespace YACS
46{
47
52template <class T=YACS::ENGINE::InlineNode*>
54{
56
57 virtual void onStart(const XML_Char* el, const XML_Char** attr)
58 {
59 DEBTRACE( "nodetypeParser::onStart: " << el )
60 std::string element(el);
62 this->SetUserDataAndPush(pp);
63 pp->init();
64 pp->pre();
65 pp->buildAttr(attr);
66 }
67 virtual void onEnd(const char *el,parser* child)
68 {
69 DEBTRACE( "nodetypeParser::onEnd: " << el )
70 std::string element(el);
71 }
72 virtual void buildAttr(const XML_Char** attr)
73 {
74 if (!attr)
75 return;
76 required("name",attr);
77 required("type",attr);
78 for (int i = 0; attr[i]; i += 2)
79 {
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]);
83 }
84 }
85 virtual void pre()
86 {
87 _node=0;
88 _container="";
89 }
90 virtual void name (const std::string& name)
91 {
92 DEBTRACE( "inline_name: " << name )
93 _name=name;
94 }
95 virtual void state (const std::string& name)
96 {
98 }
99 virtual void type (const std::string& name)
100 {
101 DEBTRACE( "node_type " << name )
102 _type=name;
103 }
104 virtual void property (const myprop& prop);
105 virtual T post();
106 std::string _type;
107 std::string _name;
108 std::string _state;
109 std::string _container;
111};
112
114
115template <class T>
117{
118 if(this->_node==0)
119 throw YACS::Exception("Node must be completely defined before setting its properties");
120 _node->setProperty(prop._name,prop._value);
121}
122
123template <class T>
125{
126 return _node;
127}
128
129template <>
131{
132 std::string fullname = currentProc->names.back()+_type;
133 if(currentProc->inlineMap.count(_type) != 0)
134 {
135 //InlineNode type with absolute name found
137 _node=n->cloneNode(_name);
138 }
139 else if(currentProc->inlineMap.count(fullname) != 0)
140 {
141 //InlineNode type with relative name found
143 _node=n->cloneNode(_name);
144 }
145 else
146 {
147 throw YACS::Exception("Unknown InlineNode type");
148 }
149 if(_state == "disabled")_node->exDisabledState();
150 DEBTRACE( "node_post " << _node->getName() )
151 return _node;
152}
153
154} // end of namespace YACS
155
156#endif
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
Class for calculation node (script) inlined (and executed) in the schema.
Definition: InlineNode.hxx:44
Base class for all schema objects.
Definition: Proc.hxx:44
std::map< std::string, InlineNode * > inlineMap
Definition: Proc.hxx:89
std::vector< std::string > names
Definition: Proc.hxx:93
char XML_Char
Definition: parserBase.hxx:37
YACS::ENGINE::Runtime * theRuntime
Definition: parsers.cxx:40
YACS::ENGINE::Proc * currentProc
Definition: parserBase.cxx:30
Class for node parser.
Definition: nodeParsers.hxx:54
virtual void property(const myprop &prop)
virtual void state(const std::string &name)
Definition: nodeParsers.hxx:95
virtual void name(const std::string &name)
Definition: nodeParsers.hxx:90
virtual void onEnd(const char *el, parser *child)
Definition: nodeParsers.hxx:67
virtual void onStart(const XML_Char *el, const XML_Char **attr)
Definition: nodeParsers.hxx:57
virtual void pre()
Definition: nodeParsers.hxx:85
static nodetypeParser< T > nodeParser
Definition: nodeParsers.hxx:55
virtual void type(const std::string &name)
Definition: nodeParsers.hxx:99
std::string _container
virtual void buildAttr(const XML_Char **attr)
Definition: nodeParsers.hxx:72
virtual void init()
Definition: parserBase.cxx:86
virtual void pre()
Definition: parserBase.hxx:61
virtual void SetUserDataAndPush(parser *pp)
Definition: parserBase.cxx:55
virtual void required(const std::string &name, const XML_Char **attr)
Definition: parserBase.cxx:186
virtual void buildAttr(const XML_Char **attr)
Definition: parserBase.cxx:195
static parser main_parser
Definition: parserBase.hxx:41
std::string _name
Definition: factory.hxx:96
std::string _value
Definition: factory.hxx:97