Version: 8.3.0
ConditionInputPort.cxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2016 CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #include "ConditionInputPort.hxx"
21 #include "WhileLoop.hxx"
22 #include "OutputPort.hxx"
23 #include <iostream>
24 #include <string>
25 
26 using namespace YACS::ENGINE;
27 using namespace std;
28 
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)
32 {
33 }
34 
35 ConditionInputPort::ConditionInputPort(const ConditionInputPort& other, Node *newHelder):InputPort(other,newHelder),
36  DataPort(other,newHelder),Port(other,newHelder),
37  _outOfScopeBackLink(0),_value(0)
38 {
39  if(other._value)
40  _value=other._value->clone();
41 }
42 
44 {
45  if(_value)
46  _value->decrRef();
47 }
48 
50 {
54 }
55 
57 {
58  if(!_initValue)
59  return;
60  if(_value)
61  _value->decrRef();
63  _value->incrRef();
64 }
65 
67 {
68  return new ConditionInputPort(*this,newHelder);
69 }
70 
72 {
73  return _outOfScopeBackLink!=0;
74 }
75 
77 {
78  if(!((ComposedNode*)(_node))->isInMyDescendance(fromPort->getNode()))
79  {
81  throw Exception("ConditionInputPort::edNotifyReferenced : already linked from outside");
82  _outOfScopeBackLink=fromPort;
83  }
85 }
86 
88 {
89  if(fromPort==_outOfScopeBackLink)
91  else
92  if(!((ComposedNode*)(_node))->isInMyDescendance(fromPort->getNode()))
93  throw Exception("ConditionInputPort::edNotifyDereferencedBy link does not exists");
95 }
96 
98 {
99  return (void *)_value;
100 }
101 
102 void ConditionInputPort::put(const void *data) throw(ConversionException)
103 {
104  put((Any*)data);
105 }
106 
108 {
109  if(_value)
110  _value->decrRef();
111  _value=data;
112  _value->incrRef();
113 }
114 
116 {
117  string xmldump;
118  if (_value->getBoolValue())
119  xmldump="<value><boolean>true</boolean></value>\n";
120  else
121  xmldump="<value><boolean>false</boolean></value>\n";
122  return xmldump;
123 }
124 
126 {
127  return (getValue() ? "True" : "False");
128 }
129