Salome HOME
Updated copyright comment
[modules/yacs.git] / src / runtime / XMLPorts.cxx
1 // Copyright (C) 2006-2024  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 "XMLPorts.hxx"
21
22 #include <iostream>
23
24 //#define _DEVDEBUG_
25 #include "YacsTrace.hxx"
26
27 using namespace YACS::ENGINE;
28 using namespace std;
29
30 InputXmlPort::InputXmlPort(const std::string& name, Node * node, TypeCode * type)
31   : InputPort(name, node, type), DataPort(name, node, type), Port(node), _initData(""), _data("")
32 {
33 }
34
35 InputXmlPort::InputXmlPort(const InputXmlPort& other, Node *newHelder):InputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder),_initData(other._initData),_data(other._data)
36 {
37 }
38
39 bool InputXmlPort::edIsManuallyInitialized() const
40 {
41   return _initData != "";
42 }
43
44 void InputXmlPort::edRemoveManInit()
45 {
46   _initData="";
47   InputPort::edRemoveManInit();
48 }
49
50 const char *InputXmlPort::getXml() const
51 {
52   DEBTRACE(_data);
53   return _data.c_str();
54 }
55
56 void *InputXmlPort::get() const
57 {
58   return (void *) _data.c_str();
59 }
60
61 void InputXmlPort::put(const void *data)
62 {
63   DEBTRACE("put(void *)");
64   put((const char*)data);
65 }
66
67 void InputXmlPort::put(const char *data)
68 {
69   DEBTRACE(data);
70   _data = data;
71 }
72
73 void InputXmlPort::releaseData()
74 {//nothing because _data has no ref counter
75 }
76
77 bool InputXmlPort::isEmpty()
78 {
79   return _data.empty();
80 }
81
82 InputPort *InputXmlPort::clone(Node *newHelder) const
83 {
84   return new InputXmlPort(*this,newHelder);
85 }
86
87 //! Save the current data value for further reinitialization of the port
88 /*!
89  *
90  */
91 void InputXmlPort::exSaveInit()
92 {
93   _initData=_data;
94 }
95
96 //! Restore the saved data value to current data value
97 /*!
98  * If no data has been saved (_initData == 0) don't restore
99  */
100 void InputXmlPort::exRestoreInit()
101 {
102   if(_initData!="")return;
103   _data=_initData;
104 }
105
106 std::string InputXmlPort::dump()
107 {
108   return _data;
109 }
110
111 std::string InputXmlPort::valToStr()
112 {
113   return _data;
114 }
115
116 void InputXmlPort::valFromStr(std::string valstr)
117 {
118   _data = valstr;
119 }
120
121
122 OutputXmlPort::OutputXmlPort(const std::string& name, Node* node, TypeCode * type)
123   : OutputPort(name, node, type), DataPort(name, node, type), Port(node)
124 {
125 }
126
127 OutputXmlPort::OutputXmlPort(const OutputXmlPort& other, Node *newHelder):OutputPort(other,newHelder),DataPort(other,newHelder),
128                                                                           Port(other,newHelder),_data(other._data)
129 {
130 }
131
132 const char * OutputXmlPort::get() const
133 {
134   return _data.c_str();
135 }
136
137 void OutputXmlPort::put(const void *data)
138 {
139   put((const char*)data);
140 }
141
142 void OutputXmlPort::put(const char *data)
143 {
144   DEBTRACE(data);
145   InputPort *p;
146   _data=data;
147   OutputPort::put(data);
148 }
149
150 OutputPort *OutputXmlPort::clone(Node *newHelder) const
151 {
152   return new OutputXmlPort(*this,newHelder);
153 }
154
155 std::string OutputXmlPort::dump()
156 {
157   return _data;
158 }
159
160 std::string OutputXmlPort::valToStr()
161 {
162   return _data;
163 }
164
165 void OutputXmlPort::valFromStr(std::string valstr)
166 {
167   _data = valstr;
168 }
169