2 #include "PresetNode.hxx"
3 #include "PresetPorts.hxx"
11 #include "YacsTrace.hxx"
13 using namespace YACS::ENGINE;
16 const char PresetNode::IMPL_NAME[]="XML";
18 PresetNode::PresetNode(const std::string& name)
21 _implementation=IMPL_NAME;
24 PresetNode::PresetNode(const PresetNode& other, ComposedNode *father)
25 : DataNode(other, father)
29 OutputPort* PresetNode::createOutputPort(const std::string& outputPortName, TypeCode* type)
31 return new OutputPresetPort(outputPortName, this, type);
34 void PresetNode::execute()
36 DEBTRACE("+++++++ PresetNode::execute +++++++++++");
37 list<OutputPort *>::const_iterator iter;
38 for(iter = _setOfOutputPort.begin(); iter != _setOfOutputPort.end(); iter++)
40 OutputPresetPort *outp = dynamic_cast<OutputPresetPort *>(*iter);
42 string data = outp->getData();
43 DEBTRACE("data: " << data );
44 outp->put(data.c_str());
46 DEBTRACE("+++++++ end PresetNode::execute +++++++++++" );
49 void PresetNode::accept(Visitor *visitor)
51 visitor->visitPresetNode(this);
54 void PresetNode::setData(OutputPort* port, std::string& data)
56 OutputPresetPort *outp = dynamic_cast<OutputPresetPort *>(port);
60 void PresetNode::checkBasicConsistency() const throw(Exception)
62 DEBTRACE("PresetNode::checkBasicConsistency");
63 if (! _setOfInputPort.empty())
65 string what = "PresetNode ";
67 what += " only accepts OutputPresetPorts, no InputPorts";
68 throw Exception(what);
71 list<OutputPort *>::const_iterator iter;
72 for(iter=_setOfOutputPort.begin();iter!=_setOfOutputPort.end();iter++)
74 OutputPresetPort *preset = dynamic_cast<OutputPresetPort*>(*iter);
77 string what("Output port: ");
78 what += (*iter)->getName();
79 what += " is not an OutputPresetPort. PresetNode ";
81 what += "only accepts OutputPresetPorts";
82 throw Exception(what);
84 preset->checkBasicConsistency();
88 Node *PresetNode::simpleClone(ComposedNode *father, bool editionOnly) const
90 return new PresetNode(*this,father);