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 "TypeConversions.hxx"
21 #include "CppPorts.hxx"
23 #include "TypeCode.hxx"
29 #include "YacsTrace.hxx"
31 using namespace YACS::ENGINE;
34 InputCppPort::InputCppPort(const std::string& name, Node *node, TypeCode * type)
35 : InputPort(name, node, type), DataPort(name, node, type), Port(node), _data(NULL),_initData(NULL)
39 InputCppPort::~InputCppPort()
43 DEBTRACE("_data ref count: " << _data->getRefCnt());
48 InputCppPort::InputCppPort(const InputCppPort& other, Node *newHelder):InputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder)
50 _initData=other._initData;
54 bool InputCppPort::edIsManuallyInitialized() const
56 return _initData!= NULL;
59 void InputCppPort::edRemoveManInit()
62 InputPort::edRemoveManInit();
65 void InputCppPort::put(const void *data) throw(ConversionException)
67 put((YACS::ENGINE::Any *)data);
70 void InputCppPort::put(YACS::ENGINE::Any *data) throw(ConversionException)
76 DEBTRACE("value ref count: " << _data->getRefCnt());
79 InputPort *InputCppPort::clone(Node *newHelder) const
81 return new InputCppPort(*this,newHelder);
84 YACS::ENGINE::Any * InputCppPort::getCppObj() const
89 void *InputCppPort::get() const throw(YACS::Exception)
94 bool InputCppPort::isEmpty()
99 //! Save the current data value for further reinitialization of the port
103 void InputCppPort::exSaveInit()
106 //DEBTRACE("_initData.ob refcnt: " << _initData->ob_refcnt);
107 //DEBTRACE("_data.ob refcnt: " << _data->ob_refcnt);
110 //! Restore the saved data value to current data value
112 * If no data has been saved (_initData == 0) don't restore
114 void InputCppPort::exRestoreInit()
116 if(!_initData)return;
118 //DEBTRACE("_initData.ob refcnt: " << _initData->ob_refcnt);
119 //DEBTRACE("_data.ob refcnt: " << _data->ob_refcnt);
122 std::string InputCppPort::dump()
125 return "<value>None</value>";
127 if (edGetType()->kind() != YACS::ENGINE::Objref)
128 return convertNeutralXml(edGetType(), _data);
129 //return convertCppXml(edGetType(), _data);
130 if (! _stringRef.empty())
133 return convertNeutralXml(edGetType(), _data);
136 // msg << "Cannot retreive init reference string for port " << _name
137 // << " on node " << _node->getName();
138 // throw Exception(msg.str());
143 OutputCppPort::OutputCppPort(const std::string& name, Node *node, TypeCode * type)
144 : OutputPort(name, node, type), DataPort(name, node, type), Port(node)
149 OutputCppPort::~OutputCppPort()
153 DEBTRACE("_data ref count: " << _data->getRefCnt());
158 OutputCppPort::OutputCppPort(const OutputCppPort& other, Node *newHelder):OutputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder),
163 void OutputCppPort::put(const void *data) throw(ConversionException)
165 put((YACS::ENGINE::Any *)data);
168 void OutputCppPort::put(YACS::ENGINE::Any *data) throw(ConversionException)
176 OutputPort::put(data);
179 OutputPort *OutputCppPort::clone(Node *newHelder) const
181 return new OutputCppPort(*this,newHelder);
184 YACS::ENGINE::Any * OutputCppPort::get() const
189 std::string OutputCppPort::dump()
192 return "<value>None</value>";
193 string xmldump = convertNeutralXml(edGetType(), _data);