1 // Copyright (C) 2006-2024 CEA, EDF
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 "PresetPorts.hxx"
21 #include "PresetNode.hxx"
22 #include "Visitor.hxx"
29 #include "YacsTrace.hxx"
31 using namespace YACS::ENGINE;
34 /*! \class YACS::ENGINE::PresetNode
35 * \brief Class for data in node
40 const char PresetNode::IMPL_NAME[]="XML";
42 PresetNode::PresetNode(const std::string& name)
45 _implementation=IMPL_NAME;
48 PresetNode::PresetNode(const PresetNode& other, ComposedNode *father)
49 : DataNode(other, father)
53 OutputPort* PresetNode::createOutputPort(const std::string& outputPortName, TypeCode* type)
55 return new OutputPresetPort(outputPortName, this, type);
58 void PresetNode::execute()
60 DEBTRACE("+++++++ PresetNode::execute +++++++++++");
61 list<OutputPort *>::const_iterator iter;
62 for(iter = _setOfOutputPort.begin(); iter != _setOfOutputPort.end(); iter++)
64 OutputPresetPort *outp = dynamic_cast<OutputPresetPort *>(*iter);
66 string data = outp->getData();
67 DEBTRACE("data: " << data );
68 outp->put(data.c_str());
70 DEBTRACE("+++++++ end PresetNode::execute +++++++++++" );
73 void PresetNode::accept(Visitor *visitor)
75 visitor->visitPresetNode(this);
78 void PresetNode::setData(OutputPort* port, const std::string& data)
80 OutputPresetPort *outp = dynamic_cast<OutputPresetPort *>(port);
84 void PresetNode::checkBasicConsistency() const
86 DEBTRACE("PresetNode::checkBasicConsistency");
87 if (! _setOfInputPort.empty())
89 string what = "PresetNode ";
91 what += " only accepts OutputPresetPorts, no InputPorts";
92 throw Exception(what);
95 list<OutputPort *>::const_iterator iter;
96 for(iter=_setOfOutputPort.begin();iter!=_setOfOutputPort.end();iter++)
98 OutputPresetPort *preset = dynamic_cast<OutputPresetPort*>(*iter);
101 string what("Output port: ");
102 what += (*iter)->getName();
103 what += " is not an OutputPresetPort. PresetNode ";
105 what += "only accepts OutputPresetPorts";
106 throw Exception(what);
108 preset->checkBasicConsistency();
112 Node *PresetNode::simpleClone(ComposedNode *father, bool editionOnly) const
114 return new PresetNode(*this,father);