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 "ConditionInputPort.hxx"
21 #include "WhileLoop.hxx"
22 #include "OutputPort.hxx"
26 using namespace YACS::ENGINE;
29 ConditionInputPort::ConditionInputPort(const std::string& name, WhileLoop *node):InputPort(name,node,Runtime::_tc_bool),
30 DataPort(name,node,Runtime::_tc_bool),
31 Port(node),_outOfScopeBackLink(0),_value(0)
35 ConditionInputPort::ConditionInputPort(const ConditionInputPort& other, Node *newHelder):InputPort(other,newHelder),
36 DataPort(other,newHelder),Port(other,newHelder),
37 _outOfScopeBackLink(0),_value(0)
40 _value=other._value->clone();
43 ConditionInputPort::~ConditionInputPort()
49 void ConditionInputPort::exSaveInit()
51 if(_initValue) _initValue->decrRef();
53 _initValue->incrRef();
56 void ConditionInputPort::exRestoreInit()
66 InputPort *ConditionInputPort::clone(Node *newHelder) const
68 return new ConditionInputPort(*this,newHelder);
71 bool ConditionInputPort::isLinkedOutOfScope() const
73 return _outOfScopeBackLink!=0;
76 void ConditionInputPort::edNotifyReferencedBy(OutPort *fromPort)
78 if(!((ComposedNode*)(_node))->isInMyDescendance(fromPort->getNode()))
80 if(_outOfScopeBackLink)
81 throw Exception("ConditionInputPort::edNotifyReferenced : already linked from outside");
82 _outOfScopeBackLink=fromPort;
84 InputPort::edNotifyReferencedBy(fromPort);
87 void ConditionInputPort::edNotifyDereferencedBy(OutPort *fromPort)
89 if(fromPort==_outOfScopeBackLink)
90 _outOfScopeBackLink=0;
92 if(!((ComposedNode*)(_node))->isInMyDescendance(fromPort->getNode()))
93 throw Exception("ConditionInputPort::edNotifyDereferencedBy link does not exists");
94 InputPort::edNotifyDereferencedBy(fromPort);
97 void *ConditionInputPort::get() const
99 return (void *)_value;
102 void ConditionInputPort::put(const void *data) throw(ConversionException)
107 void ConditionInputPort::put(Any *data) throw(ConversionException)
115 std::string ConditionInputPort::dump()
118 if (_value->getBoolValue())
119 xmldump="<value><boolean>true</boolean></value>\n";
121 xmldump="<value><boolean>false</boolean></value>\n";
125 std::string ConditionInputPort::getAsString()
127 return (getValue() ? "True" : "False");