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