Version: 8.3.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
43
ConditionInputPort::~ConditionInputPort
()
44
{
45
if
(
_value
)
46
_value
->
decrRef
();
47
}
48
49
void
ConditionInputPort::exSaveInit
()
50
{
51
if
(
_initValue
)
_initValue
->
decrRef
();
52
_initValue
=
_value
;
53
_initValue
->
incrRef
();
54
}
55
56
void
ConditionInputPort::exRestoreInit
()
57
{
58
if
(!
_initValue
)
59
return
;
60
if
(
_value
)
61
_value
->
decrRef
();
62
_value
=
_initValue
;
63
_value
->
incrRef
();
64
}
65
66
InputPort
*
ConditionInputPort::clone
(
Node
*newHelder)
const
67
{
68
return
new
ConditionInputPort
(*
this
,newHelder);
69
}
70
71
bool
ConditionInputPort::isLinkedOutOfScope
()
const
72
{
73
return
_outOfScopeBackLink
!=0;
74
}
75
76
void
ConditionInputPort::edNotifyReferencedBy
(
OutPort
*fromPort)
77
{
78
if
(!((
ComposedNode
*)(
_node
))->isInMyDescendance(fromPort->
getNode
()))
79
{
80
if
(
_outOfScopeBackLink
)
81
throw
Exception
(
"ConditionInputPort::edNotifyReferenced : already linked from outside"
);
82
_outOfScopeBackLink
=fromPort;
83
}
84
InputPort::edNotifyReferencedBy
(fromPort);
85
}
86
87
void
ConditionInputPort::edNotifyDereferencedBy
(
OutPort
*fromPort)
88
{
89
if
(fromPort==
_outOfScopeBackLink
)
90
_outOfScopeBackLink
=0;
91
else
92
if
(!((
ComposedNode
*)(
_node
))->isInMyDescendance(fromPort->
getNode
()))
93
throw
Exception
(
"ConditionInputPort::edNotifyDereferencedBy link does not exists"
);
94
InputPort::edNotifyDereferencedBy
(fromPort);
95
}
96
97
void
*
ConditionInputPort::get
()
const
98
{
99
return
(
void
*)
_value
;
100
}
101
102
void
ConditionInputPort::put
(
const
void
*data)
throw
(
ConversionException
)
103
{
104
put((
Any
*)data);
105
}
106
107
void
ConditionInputPort::put
(
Any
*data)
throw
(
ConversionException
)
108
{
109
if
(_value)
110
_value->decrRef();
111
_value=data;
112
_value->incrRef();
113
}
114
115
std::string
ConditionInputPort::dump
()
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
125
std::string
ConditionInputPort::getAsString
()
126
{
127
return
(
getValue
() ?
"True"
:
"False"
);
128
}
129
src
engine
ConditionInputPort.cxx
Copyright © 2006-2017 CEA/DEN, EDF R&D