Version: 9.16.0
ConditionInputPort.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
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
21#include "WhileLoop.hxx"
22#include "OutputPort.hxx"
23#include <iostream>
24#include <string>
25
26using namespace YACS::ENGINE;
27using namespace std;
28
29ConditionInputPort::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
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
76void ConditionInputPort::edNotifyReferencedBy(OutPort *fromPort, bool isLoopProof)
77{
78 if(!((ComposedNode*)(_node))->isInMyDescendance(fromPort->getNode()))
79 {
81 throw Exception("ConditionInputPort::edNotifyReferenced : already linked from outside");
82 _outOfScopeBackLink=fromPort;
83 }
84 InputPort::edNotifyReferencedBy(fromPort,isLoopProof);
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
102void ConditionInputPort::put(const void *data)
103{
104 put((Any*)data);
105}
106
108{
109 if(_value)
110 _value->decrRef();
111 _value=nullptr;
112}
113
115{
117 _value=data;
118 _value->incrRef();
119}
120
122{
123 string xmldump;
124 if (_value->getBoolValue())
125 xmldump="<value><boolean>true</boolean></value>\n";
126 else
127 xmldump="<value><boolean>false</boolean></value>\n";
128 return xmldump;
129}
130
132{
133 return (getValue() ? "True" : "False");
134}
135
: Interface for management of storage of data formated dynamically in its TypeCode....
Definition: Any.hxx:79
virtual bool getBoolValue() const =0
virtual Any * clone() const =0
Base class for all composed nodes.
virtual void put(const void *data)
void edNotifyReferencedBy(OutPort *fromPort, bool isLoopProof) override
virtual std::string getAsString()
returns port value as a string that can be used in a GUI for example
InputPort * clone(Node *newHelder) const
void edNotifyDereferencedBy(OutPort *fromPort)
ConditionInputPort(const std::string &name, WhileLoop *node)
virtual void edNotifyDereferencedBy(OutPort *fromPort)
Definition: InPort.cxx:102
virtual void edNotifyReferencedBy(OutPort *fromPort, bool isLoopProof=true)
Definition: InPort.cxx:93
Base class for Input Ports.
Definition: InputPort.hxx:44
Base class for all nodes.
Definition: Node.hxx:70
Base class for all ports.
Definition: Port.hxx:43
Node * getNode() const
Definition: Port.hxx:46
Node * _node
Definition: Port.hxx:55
Class for a while loop.
Definition: WhileLoop.hxx:39