1 #ifndef _OUTPUTPARSERS_HXX_
2 #define _OUTPUTPARSERS_HXX_
4 #include "nodeParsers.hxx"
8 #include "DataNode.hxx"
13 /*! \brief Class for outputdata parser.
17 <xsd:complexType name="OutputDataType">
18 <xsd:attribute name="name" type="xsd:string" use="required"/>
19 <xsd:attribute name="type" type="xsd:string" use="required"/>
20 <xsd:attribute name="ref" type="xsd::string" />
24 struct outputdatatypeParser: parser
26 static outputdatatypeParser outputdataParser;
28 virtual void onStart(const XML_Char* el, const XML_Char** attr)
30 DEBTRACE("outputdatatypeParser::onStart");
31 std::string element(el);
32 parser* pp=&parser::main_parser;
33 SetUserDataAndPush(pp);
38 virtual void onEnd(const char *el,parser* child)
41 virtual void buildAttr(const XML_Char** attr)
43 DEBTRACE("outputdatatypeParser::buildAttr");
44 required("name",attr);
45 required("type",attr);
46 for (int i = 0; attr[i]; i += 2)
48 if(std::string(attr[i]) == "name")name(attr[i+1]);
49 if(std::string(attr[i]) == "type")type(attr[i+1]);
50 if(std::string(attr[i]) == "ref")ref(attr[i+1]);
53 virtual void name (const std::string& name)
55 DEBTRACE("outputdatatypeParser::name");
58 virtual void type (const std::string& type)
60 DEBTRACE("outputdatatypeParser::type");
63 virtual void ref (const std::string& ref)
65 _param.setProperty("ref",ref);
70 DEBTRACE("outputdatatypeParser::pre");
73 virtual myoutport& post()
80 /*! \brief Class for OutNode parser.
84 <xsd:complexType name="OutNodeType">
85 <xsd:attribute name="name" type="xsd:string" use="required"/>
86 <xsd:attribute name="kind" type="xsd:string" />
87 <xsd:attribute name="ref" type="xsd:string" />
88 <xsd:element name="parameter" type="OutputDataType"/>
92 template <class T=ENGINE::DataNode*>
93 struct outnodetypeParser:public nodetypeParser<T>
95 static outnodetypeParser<T> outnodeParser;
96 virtual void onStart(const XML_Char* el, const XML_Char** attr);
97 virtual void onEnd(const char *el,parser* child);
98 virtual void buildAttr(const XML_Char** attr);
100 virtual void name (const std::string& name);
101 virtual void kind (const std::string& kind);
102 virtual void ref (const std::string& ref);
103 virtual void create ();
104 virtual void parameter (myoutport& p);
111 template <class T> outnodetypeParser<T> outnodetypeParser<T>::outnodeParser;
115 void outnodetypeParser<T>::onStart(const XML_Char* el, const XML_Char** attr)
117 DEBTRACE("outnodetypeParser::onStart");
118 std::string element(el);
119 parser* pp=&parser::main_parser;
120 if(element == "parameter")pp=&outputdatatypeParser::outputdataParser;
121 if(element == "property")pp=&propertytypeParser::propertyParser;
122 this->SetUserDataAndPush(pp);
129 void outnodetypeParser<T>::onEnd(const char *el,parser* child)
131 DEBTRACE("outnodetypeParser::onEnd");
132 std::string element(el);
133 if(element == "parameter")parameter(((outputdatatypeParser*)child)->post());
134 if(element == "property")this->property(((propertytypeParser*)child)->post());
138 void outnodetypeParser<T>::buildAttr(const XML_Char** attr)
140 DEBTRACE("outnodetypeParser::buildAttr");
141 this->required("name",attr);
142 for (int i = 0; attr[i]; i += 2)
144 if(std::string(attr[i]) == "name")name(attr[i+1]);
145 if(std::string(attr[i]) == "kind")kind(attr[i+1]);
146 if(std::string(attr[i]) == "ref")ref(attr[i+1]);
152 void outnodetypeParser<T>::pre ()
160 void outnodetypeParser<T>::name (const std::string& name)
165 void outnodetypeParser<T>::kind (const std::string& kind)
170 void outnodetypeParser<T>::ref (const std::string& ref)
176 void outnodetypeParser<T>::create ()
178 this->_node = theRuntime->createOutDataNode(_kind,_name);
182 void outnodetypeParser<T>::parameter (myoutport& p)
184 DEBTRACE("outnodetypeParser::parameter");
185 if(currentProc->typeMap.count(p._type)==0)
187 //Check if the typecode is defined in the runtime
188 YACS::ENGINE::TypeCode* t=theRuntime->getTypeCode(p._type);
191 std::string msg="Unknown Type: ";
192 msg=msg+p._type+" for node: "+this->_node->getName()+" port name: "+p._name;
198 currentProc->typeMap[p._type]=t;
202 ENGINE::InputPort *port = this->_node->edAddInputPort(p._name,currentProc->typeMap[p._type]);
203 this->_node->setData(port,p._props["ref"]);
207 T outnodetypeParser<T>::post()
209 this->_node->setRef(_ref);