Version: 9.16.0
PresetNode.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 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 "PresetPorts.hxx"
21#include "PresetNode.hxx"
22#include "Visitor.hxx"
23
24#include <iostream>
25#include <set>
26#include <cassert>
27
28//#define _DEVDEBUG_
29#include "YacsTrace.hxx"
30
31using namespace YACS::ENGINE;
32using namespace std;
33
40const char PresetNode::IMPL_NAME[]="XML";
41
42PresetNode::PresetNode(const std::string& name)
43 : DataNode(name)
44{
46}
47
49 : DataNode(other, father)
50{
51}
52
53OutputPort* PresetNode::createOutputPort(const std::string& outputPortName, TypeCode* type)
54{
55 return new OutputPresetPort(outputPortName, this, type);
56}
57
59{
60 DEBTRACE("+++++++ PresetNode::execute +++++++++++");
61 list<OutputPort *>::const_iterator iter;
62 for(iter = _setOfOutputPort.begin(); iter != _setOfOutputPort.end(); iter++)
63 {
64 OutputPresetPort *outp = dynamic_cast<OutputPresetPort *>(*iter);
65 YASSERT(outp);
66 string data = outp->getData();
67 DEBTRACE("data: " << data );
68 outp->put(data.c_str());
69 }
70 DEBTRACE("+++++++ end PresetNode::execute +++++++++++" );
71}
72
74{
75 visitor->visitPresetNode(this);
76}
77
78void PresetNode::setData(OutputPort* port, const std::string& data)
79{
80 OutputPresetPort *outp = dynamic_cast<OutputPresetPort *>(port);
81 outp->setData(data);
82}
83
85{
86 DEBTRACE("PresetNode::checkBasicConsistency");
87 if (! _setOfInputPort.empty())
88 {
89 string what = "PresetNode ";
90 what += getName();
91 what += " only accepts OutputPresetPorts, no InputPorts";
92 throw Exception(what);
93 }
94
95 list<OutputPort *>::const_iterator iter;
96 for(iter=_setOfOutputPort.begin();iter!=_setOfOutputPort.end();iter++)
97 {
98 OutputPresetPort *preset = dynamic_cast<OutputPresetPort*>(*iter);
99 if (!preset)
100 {
101 string what("Output port: ");
102 what += (*iter)->getName();
103 what += " is not an OutputPresetPort. PresetNode ";
104 what += getName();
105 what += "only accepts OutputPresetPorts";
106 throw Exception(what);
107 }
108 preset->checkBasicConsistency();
109 }
110}
111
112Node *PresetNode::simpleClone(ComposedNode *father, bool editionOnly) const
113{
114 return new PresetNode(*this,father);
115}
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
Base class for all composed nodes.
Class for data parameters specification.
Definition: DataNode.hxx:38
std::list< InputPort * > _setOfInputPort
std::list< OutputPort * > _setOfOutputPort
Base class for all nodes.
Definition: Node.hxx:70
const std::string & getName() const
Definition: Node.hxx:125
std::string _implementation
Definition: Node.hxx:97
Class for PRESET output Ports.
Definition: PresetPorts.hxx:33
virtual void checkBasicConsistency() const
Check validity of output port. Nothing on base class.
Definition: PresetPorts.cxx:66
void setData(std::string data)
Definition: PresetPorts.cxx:59
virtual void put(const void *data)
Definition: XMLPorts.cxx:137
Class for data in node.
Definition: PresetNode.hxx:31
virtual void setData(OutputPort *port, const std::string &data)
Definition: PresetNode.cxx:78
Node * simpleClone(ComposedNode *father, bool editionOnly) const
Definition: PresetNode.cxx:112
virtual void execute()
Definition: PresetNode.cxx:58
virtual OutputPort * createOutputPort(const std::string &outputPortName, TypeCode *type)
Definition: PresetNode.cxx:53
virtual void accept(Visitor *visitor)
Definition: PresetNode.cxx:73
PresetNode(const std::string &name)
Definition: PresetNode.cxx:42
static const char IMPL_NAME[]
Definition: PresetNode.hxx:44
virtual void checkBasicConsistency() const
Definition: PresetNode.cxx:84
Base class for all type objects.
Definition: TypeCode.hxx:68
virtual void visitPresetNode(DataNode *node)=0