Version: 9.16.0
VisitorSaveSalomeSchema.cxx
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#include "PresetPorts.hxx"
22#include "DataNode.hxx"
23#include "PresetNode.hxx"
24#include "OutNode.hxx"
25#include "StudyNodes.hxx"
26#include "ComposedNode.hxx"
27#include "StudyPorts.hxx"
28#include "TypeCode.hxx"
29
30#include <cassert>
31#include <iostream>
32#include <string>
33#include <set>
34
35
36using namespace YACS::ENGINE;
37using namespace std;
38
39//#define _DEVDEBUG_
40#include "YacsTrace.hxx"
41
42VisitorSaveSalomeSchema::VisitorSaveSalomeSchema(ComposedNode *root)
43 : VisitorSaveSchema(root)
44{
45}
46
48{
49}
50
52{
53 DEBTRACE("START visitPresetNode " << _root->getChildName(node));
54 beginCase(node);
55 int depth = depthNode(node);
56 _out << indent(depth) << "<datanode name=\"" << node->getName() << "\"";
57 string ref = node->getRef();
58 if (!ref.empty()) _out << " ref=\"" << ref << "\"";
59 if (node->getState() == YACS::DISABLED)
60 _out << " state=\"disabled\">" << endl;
61 else
62 _out << ">" << endl;
64 writeProperties(node);
65 _out << indent(depth) << "</datanode>" << endl;
66 endCase(node);
67 DEBTRACE("END visitPresetNode " << _root->getChildName(node));
68}
69
71{
72 DEBTRACE("START visitOutNode " << _root->getChildName(node));
73 beginCase(node);
74 int depth = depthNode(node);
75 _out << indent(depth) << "<outnode name=\"" << node->getName() << "\"";
76 string ref = node->getRef();
77 if (!ref.empty()) _out << " ref=\"" << ref << "\"";
78 if (node->getState() == YACS::DISABLED)
79 _out << " state=\"disabled\">" << endl;
80 else
81 _out << ">" << endl;
83 writeProperties(node);
84 _out << indent(depth) << "</outnode>" << endl;
85 endCase(node);
86 DEBTRACE("END visitOutNode " << _root->getChildName(node));
87}
88
90{
91 DEBTRACE("START visitStudyInNode " << _root->getChildName(node));
92 beginCase(node);
93 int depth = depthNode(node);
94 _out << indent(depth) << "<datanode name=\"" << node->getName() << "\" kind=\"study\"";
95 string ref = node->getRef();
96 if (!ref.empty()) _out << " ref=\"" << ref << "\"";
97 if (node->getState() == YACS::DISABLED)
98 _out << " state=\"disabled\">" << endl;
99 else
100 _out << ">" << endl;
102 writeProperties(node);
103 _out << indent(depth) << "</datanode>" << endl;
104 endCase(node);
105 DEBTRACE("END visitStudyInNode " << _root->getChildName(node));
106}
107
109{
110 DEBTRACE("START visitStudyOutNode " << _root->getChildName(node));
111 beginCase(node);
112 int depth = depthNode(node);
113 _out << indent(depth) << "<outnode name=\"" << node->getName() << "\" kind=\"study\"";
114 string ref = node->getRef();
115 if (!ref.empty()) _out << " ref=\"" << ref << "\"";
116 if (node->getState() == YACS::DISABLED)
117 _out << " state=\"disabled\">" << endl;
118 else
119 _out << ">" << endl;
121 writeProperties(node);
122 _out << indent(depth) << "</outnode>" << endl;
123 endCase(node);
124 DEBTRACE("END visitStudyOutNode " << _root->getChildName(node));
125}
126
128{
129 int depth = depthNode(node)+1;
130 list<OutputPort*> listOfOutputPorts = node->getSetOfOutputPort();
131 for (list<OutputPort*>::iterator it = listOfOutputPorts.begin(); it != listOfOutputPorts.end(); ++it)
132 {
133 _out << indent(depth) << "<parameter name=\"" << (*it)->getName() << "\" type=\""
134 << (*it)->edGetType()->name() << "\">" << endl;
135 OutputPresetPort *outp = dynamic_cast<OutputPresetPort*>(*it);
136 YASSERT(outp);
137 _out << indent(depth+1) << outp->getData();
138 _out << indent(depth) << "</parameter>" << endl;
139 }
140}
141
143{
144 int depth = depthNode(node)+1;
145 list<OutputPort*> listOfOutputPorts = node->getSetOfOutputPort();
146 for (list<OutputPort*>::iterator it = listOfOutputPorts.begin(); it != listOfOutputPorts.end(); ++it)
147 {
148 _out << indent(depth) << "<parameter name=\"" << (*it)->getName() << "\" type=\""
149 << (*it)->edGetType()->name() << "\" ref=\"";
150 OutputStudyPort *outp = dynamic_cast<OutputStudyPort*>(*it);
151 YASSERT(outp);
152 _out << outp->getData() << "\"/>" << endl;
153 }
154}
155
157{
158 int depth = depthNode(node)+1;
159 list<InputPort*> listOfInputPorts = node->getSetOfInputPort();
160 for (list<InputPort*>::iterator it = listOfInputPorts.begin(); it != listOfInputPorts.end(); ++it)
161 {
162 _out << indent(depth) << "<parameter name=\"" << (*it)->getName() << "\" type=\""
163 << (*it)->edGetType()->name() << "\"/>" << endl;
164 }
165}
166
168{
169 int depth = depthNode(node)+1;
170 list<InputPort*> listOfInputPorts = node->getSetOfInputPort();
171 for (list<InputPort*>::iterator it = listOfInputPorts.begin(); it != listOfInputPorts.end(); ++it)
172 {
173 _out << indent(depth) << "<parameter name=\"" << (*it)->getName() << "\" type=\""
174 << (*it)->edGetType()->name() << "\" ref=\"";
175 InputStudyPort *inp = dynamic_cast<InputStudyPort*>(*it);
176 YASSERT(inp);
177 _out << inp->getData() << "\"/>" << endl;
178 }
179}
180
181void YACS::ENGINE::VisitorSaveSalomeSchemaUnsafe(ComposedNode* proc, const std::string& xmlSchema)
182{
183 VisitorSaveSalomeSchema vss(proc);
184 vss.openFileSchema(xmlSchema);
185 proc->accept(&vss);
186 vss.closeFileSchema();
187}
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
Base class for all composed nodes.
std::string getChildName(const Node *node) const
void accept(Visitor *visitor)
Class for data parameters specification.
Definition: DataNode.hxx:38
virtual std::string getRef()
Definition: DataNode.cxx:39
std::list< OutputPort * > getSetOfOutputPort() const
YACS::StatesForNode getState() const
std::list< InputPort * > getSetOfInputPort() const
Class for Study input Ports.
Definition: StudyPorts.hxx:51
const std::string & getName() const
Definition: Node.hxx:125
Class for PRESET output Ports.
Definition: PresetPorts.hxx:33
Class for Study output Ports.
Definition: StudyPorts.hxx:33
virtual void writeDataNodeParameters(DataNode *node)
virtual void visitStudyOutNode(DataNode *node)
virtual void writeOutNodeParameters(DataNode *node)
virtual void visitStudyInNode(DataNode *node)
virtual void writeStudyInNodeParameters(DataNode *node)
virtual void writeStudyOutNodeParameters(DataNode *node)
virtual void visitPresetNode(DataNode *node)
Base class for all visitors that save a schema.
virtual void endCase(Node *node)
virtual void writeProperties(Node *node)
virtual void beginCase(Node *node)
void openFileSchema(std::string xmlDump)
YACSRUNTIMESALOME_EXPORT void VisitorSaveSalomeSchemaUnsafe(ComposedNode *proc, const std::string &xmlSchema)
@ DISABLED
Definition: define.hxx:50
def ref(target, callback=None)
Definition: CONNECTOR.py:120