Version: 9.15.0
InPropertyPort.cxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2025 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 
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 
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 
48 
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
63 {
65 }
66 
67 void
69 {
70  if(!_init_property_data)return;
72 }
73 
75 InPropertyPort::clone(Node *newHelder) const
76 {
77  return new InPropertyPort(*this,newHelder);
78 }
79 
80 void *
82 {
83  return (void*) _property_data;
84 }
85 
86 void
87 InPropertyPort::put(const void *data)
88 {
89  put((YACS::ENGINE::Any *)data);
90 }
91 
93 {
94  if(_property_data)
96  _property_data = nullptr;
97 }
98 
99 void
101 {
102  // Add new properties to the node
103  YACS::ENGINE::SequenceAny * seq_data = static_cast<YACS::ENGINE::SequenceAny*>(data);
104  for (int i = 0; i < seq_data->size(); i++)
105  {
106  std::string key = ((*seq_data)[i]["name"])->getStringValue();
107  std::string value = ((*seq_data)[i]["value"])->getStringValue();
108  exNewPropertyValue(key, value);
109  }
111  _property_data = data;
113  DEBTRACE("value ref count: " << _property_data->getRefCnt());
114 }
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
: Interface for management of storage of data formated dynamically in its TypeCode....
Definition: Any.hxx:79
class for Input Property Ports
virtual void put(const void *data)
YACS::ENGINE::Any * _init_property_data
InPropertyPort(const InPropertyPort &other, Node *newHelder)
YACS::ENGINE::Any * _property_data
std::string getNameOfTypeOfCurrentInstance() const
virtual void exNewPropertyValue(const std::string &name, const std::string &value)
virtual InPropertyPort * clone(Node *newHelder) const
virtual void * get() const
Base class for Input Ports.
Definition: InputPort.hxx:44
Base class for all nodes.
Definition: Node.hxx:70
virtual void setProperty(const std::string &name, const std::string &value)
Definition: Node.cxx:491
Base class for all ports.
Definition: Port.hxx:43
Node * _node
Definition: Port.hxx:55
unsigned int getRefCnt() const
Definition: RefCounter.hxx:32
unsigned int size() const
Definition: Any.hxx:209
Base class for all type objects.
Definition: TypeCode.hxx:68