1 // Copyright (C) 2006-2024 CEA, EDF
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)
67 put((YACS::ENGINE::Any *)data);
70 void InputCppPort::releaseData()
77 void InputCppPort::put(YACS::ENGINE::Any *data)
82 DEBTRACE("value ref count: " << _data->getRefCnt());
85 InputPort *InputCppPort::clone(Node *newHelder) const
87 return new InputCppPort(*this,newHelder);
90 YACS::ENGINE::Any * InputCppPort::getCppObj() const
95 void *InputCppPort::get() const
100 bool InputCppPort::isEmpty()
102 return _data == NULL;
105 //! Save the current data value for further reinitialization of the port
109 void InputCppPort::exSaveInit()
112 //DEBTRACE("_initData.ob refcnt: " << _initData->ob_refcnt);
113 //DEBTRACE("_data.ob refcnt: " << _data->ob_refcnt);
116 //! Restore the saved data value to current data value
118 * If no data has been saved (_initData == 0) don't restore
120 void InputCppPort::exRestoreInit()
122 if(!_initData)return;
124 //DEBTRACE("_initData.ob refcnt: " << _initData->ob_refcnt);
125 //DEBTRACE("_data.ob refcnt: " << _data->ob_refcnt);
128 std::string InputCppPort::dump()
131 return "<value>None</value>";
133 if (edGetType()->kind() != YACS::ENGINE::Objref)
134 return convertNeutralXml(edGetType(), _data);
135 //return convertCppXml(edGetType(), _data);
136 if (! _stringRef.empty())
139 return convertNeutralXml(edGetType(), _data);
142 // msg << "Cannot retreive init reference string for port " << _name
143 // << " on node " << _node->getName();
144 // throw Exception(msg.str());
149 OutputCppPort::OutputCppPort(const std::string& name, Node *node, TypeCode * type)
150 : OutputPort(name, node, type), DataPort(name, node, type), Port(node)
155 OutputCppPort::~OutputCppPort()
159 DEBTRACE("_data ref count: " << _data->getRefCnt());
164 OutputCppPort::OutputCppPort(const OutputCppPort& other, Node *newHelder):OutputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder),
169 void OutputCppPort::put(const void *data)
171 put((YACS::ENGINE::Any *)data);
174 void OutputCppPort::put(YACS::ENGINE::Any *data)
182 OutputPort::put(data);
185 OutputPort *OutputCppPort::clone(Node *newHelder) const
187 return new OutputCppPort(*this,newHelder);
190 YACS::ENGINE::Any * OutputCppPort::get() const
195 std::string OutputCppPort::dump()
198 return "<value>None</value>";
199 string xmldump = convertNeutralXml(edGetType(), _data);