1 // Copyright (C) 2006-2014 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 #include "PresetPorts.hxx"
21 #include "VisitorSaveSalomeSchema.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"
36 using namespace YACS::ENGINE;
40 #include "YacsTrace.hxx"
42 VisitorSaveSalomeSchema::VisitorSaveSalomeSchema(ComposedNode *root)
43 : VisitorSaveSchema(root)
47 VisitorSaveSalomeSchema::~VisitorSaveSalomeSchema()
51 void VisitorSaveSalomeSchema::visitPresetNode(DataNode *node)
53 DEBTRACE("START visitPresetNode " << _root->getChildName(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;
63 writeDataNodeParameters(node);
64 writeProperties(node);
65 _out << indent(depth) << "</datanode>" << endl;
67 DEBTRACE("END visitPresetNode " << _root->getChildName(node));
70 void VisitorSaveSalomeSchema::visitOutNode(DataNode *node)
72 DEBTRACE("START visitOutNode " << _root->getChildName(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;
82 writeOutNodeParameters(node);
83 writeProperties(node);
84 _out << indent(depth) << "</outnode>" << endl;
86 DEBTRACE("END visitOutNode " << _root->getChildName(node));
89 void VisitorSaveSalomeSchema::visitStudyInNode(DataNode *node)
91 DEBTRACE("START visitStudyInNode " << _root->getChildName(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;
101 writeStudyInNodeParameters(node);
102 writeProperties(node);
103 _out << indent(depth) << "</datanode>" << endl;
105 DEBTRACE("END visitStudyInNode " << _root->getChildName(node));
108 void VisitorSaveSalomeSchema::visitStudyOutNode(DataNode *node)
110 DEBTRACE("START visitStudyOutNode " << _root->getChildName(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;
120 writeStudyOutNodeParameters(node);
121 writeProperties(node);
122 _out << indent(depth) << "</outnode>" << endl;
124 DEBTRACE("END visitStudyOutNode " << _root->getChildName(node));
127 void VisitorSaveSalomeSchema::writeDataNodeParameters(DataNode *node)
129 int depth = depthNode(node)+1;
130 list<OutputPort*> listOfOutputPorts = node->getSetOfOutputPort();
131 for (list<OutputPort*>::iterator it = listOfOutputPorts.begin(); it != listOfOutputPorts.end(); ++it)
133 _out << indent(depth) << "<parameter name=\"" << (*it)->getName() << "\" type=\""
134 << (*it)->edGetType()->name() << "\">" << endl;
135 OutputPresetPort *outp = dynamic_cast<OutputPresetPort*>(*it);
137 _out << indent(depth+1) << outp->getData();
138 _out << indent(depth) << "</parameter>" << endl;
142 void VisitorSaveSalomeSchema::writeStudyInNodeParameters(DataNode *node)
144 int depth = depthNode(node)+1;
145 list<OutputPort*> listOfOutputPorts = node->getSetOfOutputPort();
146 for (list<OutputPort*>::iterator it = listOfOutputPorts.begin(); it != listOfOutputPorts.end(); ++it)
148 _out << indent(depth) << "<parameter name=\"" << (*it)->getName() << "\" type=\""
149 << (*it)->edGetType()->name() << "\" ref=\"";
150 OutputStudyPort *outp = dynamic_cast<OutputStudyPort*>(*it);
152 _out << outp->getData() << "\"/>" << endl;
156 void VisitorSaveSalomeSchema::writeOutNodeParameters(DataNode *node)
158 int depth = depthNode(node)+1;
159 list<InputPort*> listOfInputPorts = node->getSetOfInputPort();
160 for (list<InputPort*>::iterator it = listOfInputPorts.begin(); it != listOfInputPorts.end(); ++it)
162 _out << indent(depth) << "<parameter name=\"" << (*it)->getName() << "\" type=\""
163 << (*it)->edGetType()->name() << "\"/>" << endl;
167 void VisitorSaveSalomeSchema::writeStudyOutNodeParameters(DataNode *node)
169 int depth = depthNode(node)+1;
170 list<InputPort*> listOfInputPorts = node->getSetOfInputPort();
171 for (list<InputPort*>::iterator it = listOfInputPorts.begin(); it != listOfInputPorts.end(); ++it)
173 _out << indent(depth) << "<parameter name=\"" << (*it)->getName() << "\" type=\""
174 << (*it)->edGetType()->name() << "\" ref=\"";
175 InputStudyPort *inp = dynamic_cast<InputStudyPort*>(*it);
177 _out << inp->getData() << "\"/>" << endl;