Version: 8.3.0
XMLPorts.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 "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 
40 {
41  return _initData != "";
42 }
43 
45 {
46  _initData="";
48 }
49 
50 const char *InputXmlPort::getXml() const
51 {
52  DEBTRACE(_data);
53  return _data.c_str();
54 }
55 
56 void *InputXmlPort::get() const throw(YACS::Exception)
57 {
58  return (void *) _data.c_str();
59 }
60 
61 void InputXmlPort::put(const void *data) throw (ConversionException)
62 {
63  DEBTRACE("put(void *)");
64  put((const char*)data);
65 }
66 
67 void InputXmlPort::put(const char *data) throw (ConversionException)
68 {
69  DEBTRACE(data);
70  _data = data;
71 }
72 
74 {
75  return _data.empty();
76 }
77 
79 {
80  return new InputXmlPort(*this,newHelder);
81 }
82 
84 
88 {
90 }
91 
93 
97 {
98  if(_initData!="")return;
100 }
101 
102 std::string InputXmlPort::dump()
103 {
104  return _data;
105 }
106 
108 {
109  return _data;
110 }
111 
112 void InputXmlPort::valFromStr(std::string valstr)
113 {
114  _data = valstr;
115 }
116 
117 
118 OutputXmlPort::OutputXmlPort(const std::string& name, Node* node, TypeCode * type)
119  : OutputPort(name, node, type), DataPort(name, node, type), Port(node)
120 {
121 }
122 
123 OutputXmlPort::OutputXmlPort(const OutputXmlPort& other, Node *newHelder):OutputPort(other,newHelder),DataPort(other,newHelder),
124  Port(other,newHelder),_data(other._data)
125 {
126 }
127 
128 const char * OutputXmlPort::get() const throw (ConversionException)
129 {
130  return _data.c_str();
131 }
132 
133 void OutputXmlPort::put(const void *data) throw (ConversionException)
134 {
135  put((const char*)data);
136 }
137 
138 void OutputXmlPort::put(const char *data) throw (ConversionException)
139 {
140  DEBTRACE(data);
141  InputPort *p;
142  _data=data;
143  OutputPort::put(data);
144 }
145 
147 {
148  return new OutputXmlPort(*this,newHelder);
149 }
150 
151 std::string OutputXmlPort::dump()
152 {
153  return _data;
154 }
155 
157 {
158  return _data;
159 }
160 
161 void OutputXmlPort::valFromStr(std::string valstr)
162 {
163  _data = valstr;
164 }
165