1 // Copyright (C) 2006-2015 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 "InPropertyPort.hxx"
22 #include "TypeCode.hxx"
25 #include "YacsTrace.hxx"
27 using namespace YACS::ENGINE;
30 const char InPropertyPort::NAME[]="InPropertyPort";
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)
39 InPropertyPort::InPropertyPort(const std::string& name, Node *node, TypeCode* type, bool canBeNull)
40 : InputPort(name, node, type, canBeNull),
41 DataPort(name, node, type),
43 _property_data(NULL), _init_property_data(NULL)
47 InPropertyPort::~InPropertyPort() {}
49 string InPropertyPort::getNameOfTypeOfCurrentInstance() const
55 InPropertyPort::exNewPropertyValue(const std::string & name, const std::string & value)
57 DEBTRACE("Adding new Property to the node " << name << " " << value);
58 _node->setProperty(name, value);
62 InPropertyPort::exSaveInit()
64 _init_property_data = _property_data;
68 InPropertyPort::exRestoreInit()
70 if(!_init_property_data)return;
71 _property_data = _init_property_data;
75 InPropertyPort::clone(Node *newHelder) const
77 return new InPropertyPort(*this,newHelder);
81 InPropertyPort::get() const
83 return (void*) _property_data;
87 InPropertyPort::put(const void *data) throw(ConversionException)
89 put((YACS::ENGINE::Any *)data);
93 InPropertyPort::put(YACS::ENGINE::Any *data)
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++)
99 std::string key = ((*seq_data)[i]["name"])->getStringValue();
100 std::string value = ((*seq_data)[i]["value"])->getStringValue();
101 exNewPropertyValue(key, value);
105 _property_data->decrRef();
106 _property_data = data;
107 _property_data->incrRef();
108 DEBTRACE("value ref count: " << _property_data->getRefCnt());