Version: 8.3.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
InPropertyPort.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 "
InPropertyPort.hxx
"
21
#include "
Node.hxx
"
22
#include "
TypeCode.hxx
"
23
24
//#define _DEVDEBUG_
25
#include "
YacsTrace.hxx
"
26
27
using namespace
YACS::ENGINE;
28
using namespace
std;
29
30
const
char
InPropertyPort::NAME
[]=
"InPropertyPort"
;
31
32
InPropertyPort::InPropertyPort
(
const
InPropertyPort
& other,
Node
*newHelder)
33
:
InputPort
(other, newHelder),
34
DataPort
(other, newHelder),
35
Port
(other, newHelder),
36
_property_data(NULL), _init_property_data(NULL)
37
{}
38
39
InPropertyPort::InPropertyPort
(
const
std::string& name,
Node
*node,
TypeCode
* type,
bool
canBeNull)
40
:
InputPort
(name, node, type, canBeNull),
41
DataPort
(name, node, type),
42
Port
(node),
43
_property_data(NULL), _init_property_data(NULL)
44
{
45
}
46
47
InPropertyPort::~InPropertyPort
() {}
48
49
string
InPropertyPort::getNameOfTypeOfCurrentInstance
()
const
50
{
51
return
NAME
;
52
}
53
54
void
55
InPropertyPort::exNewPropertyValue
(
const
std::string & name,
const
std::string & value)
56
{
57
DEBTRACE
(
"Adding new Property to the node "
<< name <<
" "
<< value);
58
_node
->
setProperty
(name, value);
59
}
60
61
void
62
InPropertyPort::exSaveInit
()
63
{
64
_init_property_data
=
_property_data
;
65
}
66
67
void
68
InPropertyPort::exRestoreInit
()
69
{
70
if
(!
_init_property_data
)
return
;
71
_property_data
=
_init_property_data
;
72
}
73
74
InPropertyPort
*
75
InPropertyPort::clone
(
Node
*newHelder)
const
76
{
77
return
new
InPropertyPort
(*
this
,newHelder);
78
}
79
80
void
*
81
InPropertyPort::get
()
const
82
{
83
return
(
void
*)
_property_data
;
84
}
85
86
void
87
InPropertyPort::put
(
const
void
*data)
throw
(
ConversionException
)
88
{
89
put((
YACS::ENGINE::Any
*)data);
90
}
91
92
void
93
InPropertyPort::put
(
YACS::ENGINE::Any
*data)
94
{
95
// Add new properties to the node
96
YACS::ENGINE::SequenceAny
* seq_data =
static_cast<
YACS::ENGINE::SequenceAny
*
>
(data);
97
for
(
int
i
= 0;
i
< seq_data->
size
();
i
++)
98
{
99
std::string key = ((*seq_data)[
i
][
"name"
])->getStringValue();
100
std::string value = ((*seq_data)[
i
][
"value"
])->getStringValue();
101
exNewPropertyValue
(key, value);
102
}
103
104
if
(
_property_data
)
105
_property_data
->
decrRef
();
106
_property_data
= data;
107
_property_data
->
incrRef
();
108
DEBTRACE
(
"value ref count: "
<<
_property_data
->
getRefCnt
());
109
}
src
engine
InPropertyPort.cxx
Copyright © 2006-2017 CEA/DEN, EDF R&D