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 "PresetPorts.hxx"
22 #include "PythonPorts.hxx"
23 #include "TypeCode.hxx"
27 #include "YacsTrace.hxx"
29 using namespace YACS::ENGINE;
32 /*! \class YACS::ENGINE::OutputPresetPort
33 * \brief Class for PRESET output Ports
40 OutputPresetPort::OutputPresetPort(const std::string& name, Node* node, TypeCode* type)
41 : OutputXmlPort(name, node, type),
42 DataPort(name, node, type),
47 OutputPresetPort::OutputPresetPort(const OutputPresetPort& other, Node *newHelder)
48 : OutputXmlPort(other,newHelder),
49 DataPort(other,newHelder),
50 Port(other,newHelder),_storeData(other._storeData)
54 OutputPort* OutputPresetPort::clone(Node *newHelder) const
56 return new OutputPresetPort(*this,newHelder);
59 void OutputPresetPort::setData(std::string data)
62 DEBTRACE( "OutputPresetPort::setData " << _storeData );
66 void OutputPresetPort::checkBasicConsistency() const
68 DEBTRACE("OutputPresetPort::checkBasicConsistency " << _storeData);
69 if (_storeData.empty())
71 std::string what("OutputPresetPort: ");
73 what += " is not initialised";
74 throw Exception(what);
78 std::string OutputPresetPort::getData()
80 DEBTRACE("OutputPresetPort::getData " << _storeData);
81 if(_storeData.substr(0,7) == "<value>")
88 switch(edGetType()->kind())
91 value="<value><double>"+_storeData+"</double></value>";
94 value="<value><int>"+_storeData+"</int></value>";
97 value="<value><string>"+_storeData+"</string></value>";
100 value="<value><boolean>"+_storeData+"</boolean></value>";
103 value="<value><objref>"+_storeData+"</objref></value>";
107 value="<value><array><data>"+_storeData+"</data></array></value>";
110 value="<value><struct><data>"+_storeData+"</data></struct></value>";
119 std::string OutputPresetPort::dump()
124 PyObject * OutputPresetPort::getPyObj()
133 return convertXmlStrPyObject(edGetType(),getData());
136 std::string OutputPresetPort::getAsString()
138 InterpreterUnlocker loc;
139 PyObject* ob=getPyObj();
140 DEBTRACE(PyObject_Str(ob));
141 std::string s=convertPyObjectToString(ob);
147 /*! \class YACS::ENGINE::InputPresetPort
148 * \brief Class for PRESET input Ports
155 InputPresetPort::InputPresetPort(const std::string& name, Node* node, TypeCode* type)
156 : InputXmlPort(name, node, type),
157 DataPort(name, node, type),
162 InputPresetPort::InputPresetPort(const InputPresetPort& other, Node *newHelder)
163 : InputXmlPort(other,newHelder),
164 DataPort(other,newHelder),
165 Port(other,newHelder),_storeData(other._storeData)
169 InputPort* InputPresetPort::clone(Node *newHelder) const
171 return new InputPresetPort(*this,newHelder);
174 void InputPresetPort::setData(std::string data)
177 DEBTRACE( "InputPresetPort::setData " << _storeData );
181 std::string InputPresetPort::getData()
183 DEBTRACE("InputPresetPort::getData " << _storeData);
187 std::string InputPresetPort::dump()
192 PyObject * InputPresetPort::getPyObj()
201 return convertXmlStrPyObject(edGetType(),dump());
204 std::string InputPresetPort::getAsString()
206 InterpreterUnlocker loc;
207 PyObject* ob=getPyObj();
208 DEBTRACE(PyObject_Str(ob));
209 std::string s=convertPyObjectToString(ob);