Version: 8.3.0
VisitorSaveSalomeSchema.cxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2016 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 "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 
36 using namespace YACS::ENGINE;
37 using namespace std;
38 
39 //#define _DEVDEBUG_
40 #include "YacsTrace.hxx"
41 
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 }