+// Copyright (C) 2006-2013 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
#include "InputPort.hxx"
#include "OutPort.hxx"
#include "ComposedNode.hxx"
const char InputPort::NAME[]="InputPort";
-InputPort::InputPort(const InputPort& other, Node *newHelder):DataFlowPort(other,newHelder),InPort(other,newHelder),
- DataPort(other,newHelder),Port(other,newHelder),
- _initValue(0)
+InputPort::InputPort(const InputPort& other, Node *newHelder)
+ : DataFlowPort(other, newHelder),
+ InPort(other, newHelder),
+ DataPort(other, newHelder),
+ Port(other, newHelder),
+ _initValue(0),
+ _canBeNull(other._canBeNull)
{
if(other._initValue)
_initValue=other._initValue->clone();
}
-InputPort::InputPort(const std::string& name, Node *node, TypeCode* type)
- : DataFlowPort(name,node,type), InPort(name,node,type),DataPort(name,node,type),Port(node), _initValue(0)
+InputPort::InputPort(const std::string& name, Node *node, TypeCode* type, bool canBeNull)
+ : DataFlowPort(name, node, type),
+ InPort(name, node, type),
+ DataPort(name, node, type),
+ Port(node),
+ _initValue(0),
+ _canBeNull(canBeNull)
{
}
*/
bool InputPort::edIsInitialized() const
{
- return (edIsManuallyInitialized() or _backLinks.size()!=0 );
+ return (edIsManuallyInitialized() || _backLinks.size()!=0 );
}
InputPort::~InputPort()
void InputPort::edInit(Any *value)
{
InputPort *manuallySet=getRuntime()->adapt(this,
- Runtime::RUNTIME_ENGINE_INTERACTION_IMPL_NAME,_type);
- manuallySet->put((const void *) value);
- if(manuallySet!=this)
- delete manuallySet;
+ Runtime::RUNTIME_ENGINE_INTERACTION_IMPL_NAME,_type,true);
+ try
+ {
+ manuallySet->put((const void *) value);
+ if(manuallySet!=this)
+ delete manuallySet;
+ }
+ catch(ConversionException&)
+ {
+ if(manuallySet!=this)
+ delete manuallySet;
+ throw;
+ }
exSaveInit();
modified();
}
+//! Initialize the port with an object (value) coming from a world with implementation impl
+/*!
+ * You should be careful when using this method : the caller must set the context according to implementation
+ * For instance, if implementation is Python, the caller must hold the Global Interpreter Lock (also known as GIL).
+ */
void InputPort::edInit(const std::string& impl,const void* value)
{
- InputPort *manuallySet=getRuntime()->adapt(this,impl,_type);
- manuallySet->put(value);
- if(manuallySet!=this)
- delete manuallySet;
+ InputPort *manuallySet=getRuntime()->adapt(this,impl,_type,true);
+ try
+ {
+ manuallySet->put(value);
+ if(manuallySet!=this)
+ delete manuallySet;
+ }
+ catch(ConversionException&)
+ {
+ if(manuallySet!=this)
+ delete manuallySet;
+ throw;
+ }
exSaveInit();
modified();
}
}
//! Check basically that this port has one chance to be specified on time. It's a necessary condition \b not \b sufficient at all.
-void InputPort::checkBasicConsistency() const throw(Exception)
+void InputPort::checkBasicConsistency() const throw(YACS::Exception)
{
- if(!edIsManuallyInitialized() and _backLinks.size()==0 )
+ if(!_canBeNull && !edIsManuallyInitialized() && _backLinks.size()==0 )
{
ostringstream stream;
stream << "InputPort::checkBasicConsistency : Port " << _name << " of node with name " << _node->getName() << " neither initialized nor linked back";
_stringRef = strRef;
}
+bool InputPort::canBeNull() const
+{
+ return _canBeNull;
+}
+
ProxyPort::ProxyPort(InputPort* p):InputPort("Convertor", p->getNode(), p->edGetType()),DataPort("Convertor", p->getNode(), p->edGetType()),
Port( p->getNode())
{
*/
}
-void ProxyPort::edRemoveAllLinksLinkedWithMe() throw(Exception)
+void ProxyPort::edRemoveAllLinksLinkedWithMe() throw(YACS::Exception)
{
_port->edRemoveAllLinksLinkedWithMe();
}