1 // Copyright (C) 2006-2008 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.
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
19 #include "TypeConversions.hxx"
20 #include "PresetPorts.hxx"
21 #include "PythonPorts.hxx"
22 #include "TypeCode.hxx"
26 #include "YacsTrace.hxx"
28 using namespace YACS::ENGINE;
31 OutputPresetPort::OutputPresetPort(const std::string& name, Node* node, TypeCode* type)
32 : OutputXmlPort(name, node, type),
33 DataPort(name, node, type),
38 OutputPresetPort::OutputPresetPort(const OutputPresetPort& other, Node *newHelder)
39 : OutputXmlPort(other,newHelder),
40 DataPort(other,newHelder),
45 void OutputPresetPort::setData(std::string data)
48 DEBTRACE( "OutputPresetPort::setData " << _storeData );
52 void OutputPresetPort::checkBasicConsistency() const throw(Exception)
54 DEBTRACE("OutputPresetPort::checkBasicConsistency " << _storeData);
55 if (_storeData.empty())
57 std::string what("OutputPresetPort: ");
59 what += " is not initialised";
60 throw Exception(what);
64 std::string OutputPresetPort::getData()
66 DEBTRACE("OutputPresetPort::getData " << _storeData);
67 if(_storeData.substr(0,7) == "<value>")
74 switch(edGetType()->kind())
77 value="<value><double>"+_storeData+"</double></value>";
80 value="<value><int>"+_storeData+"</int></value>";
83 value="<value><string>"+_storeData+"</string></value>";
86 value="<value><boolean>"+_storeData+"</boolean></value>";
89 value="<value><objref>"+_storeData+"</objref></value>";
101 std::string OutputPresetPort::dump()
106 PyObject * OutputPresetPort::getPyObj()
115 return convertXmlStrPyObject(edGetType(),getData());
118 std::string OutputPresetPort::getAsString()
120 InterpreterUnlocker loc;
121 PyObject* ob=getPyObj();
122 DEBTRACE(PyObject_Str(ob));
123 std::string s=convertPyObjectToString(ob);
130 InputPresetPort::InputPresetPort(const std::string& name, Node* node, TypeCode* type)
131 : InputXmlPort(name, node, type),
132 DataPort(name, node, type),
137 InputPresetPort::InputPresetPort(const InputPresetPort& other, Node *newHelder)
138 : InputXmlPort(other,newHelder),
139 DataPort(other,newHelder),
140 Port(other,newHelder)
144 void InputPresetPort::setData(std::string data)
147 DEBTRACE( "InputPresetPort::setData " << _storeData );
151 std::string InputPresetPort::getData()
153 DEBTRACE("InputPresetPort::getData " << _storeData);
157 std::string InputPresetPort::dump()
162 PyObject * InputPresetPort::getPyObj()
171 return convertXmlStrPyObject(edGetType(),dump());
174 std::string InputPresetPort::getAsString()
176 InterpreterUnlocker loc;
177 PyObject* ob=getPyObj();
178 DEBTRACE(PyObject_Str(ob));
179 std::string s=convertPyObjectToString(ob);