3 #include "PresetPorts.hxx"
12 #include "YacsTrace.hxx"
21 const char OutNode::IMPL_NAME[]="XML";
23 OutNode::OutNode(const std::string& name)
26 _implementation=IMPL_NAME;
29 OutNode::OutNode(const OutNode& other, ComposedNode *father)
30 : DataNode(other, father)
34 InputPort* OutNode::createInputPort(const std::string& inputPortName, TypeCode* type)
36 return new InputPresetPort(inputPortName, this, type);
39 void OutNode::dump(std::ostream &out)
41 std::list<InputPort *>::const_iterator iter;
42 for(iter = _setOfInputPort.begin(); iter != _setOfInputPort.end(); iter++)
44 InputPresetPort *inp = dynamic_cast<InputPresetPort *>(*iter);
45 if(inp->getData() != "")
47 //save the file in the given reference
48 std::string xmlValue=inp->dump();
49 std::string::size_type i=xmlValue.find_first_of('/',0);
50 xmlValue=xmlValue.substr(i);
51 i=xmlValue.find_first_of('<',0);
52 std::ifstream fin(xmlValue.substr(0,i).c_str());
53 std::ofstream fout(inp->getData().c_str());
54 fout << fin.rdbuf(); // Dumps file contents to file
55 out << "<value><objref>" << inp->getData() << "</objref></value>" << std::endl;
58 out << inp->dump() << std::endl;
62 void OutNode::execute()
64 DEBTRACE("+++++++ OutNode::execute +++++++++++");
67 std::ofstream out(_ref.c_str());
72 DEBTRACE("+++++++ end OutNode::execute +++++++++++" );
75 void OutNode::accept(Visitor *visitor)
77 visitor->visitOutNode(this);
80 void OutNode::setData(InputPort* port, std::string& data)
82 InputPresetPort *inp = dynamic_cast<InputPresetPort *>(port);
86 void OutNode::checkBasicConsistency() const throw(Exception)
88 DEBTRACE("OutNode::checkBasicConsistency");
89 if (! _setOfOutputPort.empty())
91 string what = "OutNode ";
93 what += " only accepts InputPorts, no OutputPorts";
94 throw Exception(what);
96 list<InputPort *>::const_iterator iter;
97 for(iter=_setOfInputPort.begin();iter!=_setOfInputPort.end();iter++)
99 InputPresetPort *preset = dynamic_cast<InputPresetPort*>(*iter);
102 string what("Input port: ");
103 what += (*iter)->getName();
104 what += " is not an InputPresetPort. PresetNode ";
106 what += " only accepts InputPresetPorts";
107 throw Exception(what);
109 preset->checkBasicConsistency();
114 Node *OutNode::simpleClone(ComposedNode *father, bool editionOnly) const
116 return new OutNode(*this,father);