22 #include <QXmlAttributes> 24 #include <QDomDocument> 25 #include <QDomElement> 26 #include <QDomNamedNodeMap> 29 #include <QTextStream> 34 m_summaryType(NoSummary),
43 m_summaryType(NoSummary),
55 if (!doc.setContent(xml,
false, &error, &errorLine, &errorColumn)) {
56 cerr <<
"Transform::Transform: Error in parsing XML: " 57 << error <<
" at line " << errorLine
58 <<
", column " << errorColumn << endl;
59 cerr <<
"Input follows:" << endl;
61 cerr <<
"Input ends." << endl;
65 QDomElement transformElt = doc.firstChildElement(
"transform");
66 QDomNamedNodeMap attrNodes = transformElt.attributes();
69 for (
int i = 0; i < attrNodes.length(); ++i) {
70 QDomAttr attr = attrNodes.item(i).toAttr();
71 if (!attr.isNull()) attrs.append(attr.name(),
"",
"", attr.value());
76 for (QDomElement paramElt = transformElt.firstChildElement(
"parameter");
78 paramElt = paramElt.nextSiblingElement(
"parameter")) {
80 QDomNamedNodeMap paramAttrs = paramElt.attributes();
82 QDomAttr nameAttr = paramAttrs.namedItem(
"name").toAttr();
83 if (nameAttr.isNull() || nameAttr.value() ==
"")
continue;
85 QDomAttr valueAttr = paramAttrs.namedItem(
"value").toAttr();
86 if (valueAttr.isNull() || valueAttr.value() ==
"")
continue;
88 setParameter(nameAttr.value(), valueAttr.value().toFloat());
91 for (QDomElement configElt = transformElt.firstChildElement(
"configuration");
93 configElt = configElt.nextSiblingElement(
"configuration")) {
95 QDomNamedNodeMap configAttrs = configElt.attributes();
97 QDomAttr nameAttr = configAttrs.namedItem(
"name").toAttr();
98 if (nameAttr.isNull() || nameAttr.value() ==
"")
continue;
100 QDomAttr valueAttr = configAttrs.namedItem(
"value").toAttr();
101 if (valueAttr.isNull() || valueAttr.value() ==
"")
continue;
192 return pluginId +
":" + output;
197 QString &type, QString &soName,
198 QString &label, QString &output)
200 output = identifier.section(
':', 3);
202 type, soName, label);
220 return m_id.section(
':', 0, 2);
226 return m_id.section(
':', 3);
245 return pluginIdentifier +
':' + output;
282 SVDEBUG <<
"Transform::setConfigurationValue(" << name <<
") -> " << value << endl;
399 bool haveContent =
true;
402 out << QString(
"<transform\n id=\"%1\"\n pluginVersion=\"%2\"\n program=\"%3\"\n stepSize=\"%4\"\n blockSize=\"%5\"\n windowType=\"%6\"\n startTime=\"%7\"\n duration=\"%8\"\n sampleRate=\"%9\"")
417 if (extraAttributes !=
"") {
418 out <<
" " << extraAttributes;
425 for (ParameterMap::const_iterator i =
m_parameters.begin();
428 << QString(
"<parameter name=\"%1\" value=\"%2\"/>\n")
436 << QString(
"<configuration name=\"%1\" value=\"%2\"/>\n")
441 out << indent <<
"</transform>\n";
453 if (str ==
"minimum" || str ==
"min")
return Minimum;
454 if (str ==
"maximum" || str ==
"max")
return Maximum;
455 if (str ==
"mean")
return Mean;
456 if (str ==
"median")
return Median;
457 if (str ==
"mode")
return Mode;
458 if (str ==
"sum")
return Sum;
459 if (str ==
"variance")
return Variance;
460 if (str ==
"standard-deviation" || str ==
"standardDeviation" ||
462 if (str ==
"count")
return Count;
464 SVDEBUG <<
"Transform::stringToSummaryType: unknown summary type \"" 465 << str <<
"\"" << endl;
475 case Mean:
return "mean";
476 case Median:
return "median";
477 case Mode:
return "mode";
478 case Sum:
return "sum";
481 case Count:
return "count";
484 SVDEBUG <<
"Transform::summaryTypeToString: unexpected summary type " 485 << int(type) << endl;
493 if (attrs.value(
"id") !=
"") {
497 if (attrs.value(
"pluginVersion") !=
"") {
501 if (attrs.value(
"program") !=
"") {
505 if (attrs.value(
"stepSize") !=
"") {
509 if (attrs.value(
"blockSize") !=
"") {
513 if (attrs.value(
"windowType") !=
"") {
515 (attrs.value(
"windowType").toStdString()));
518 if (attrs.value(
"startTime") !=
"") {
522 if (attrs.value(
"duration") !=
"") {
526 if (attrs.value(
"sampleRate") !=
"") {
530 if (attrs.value(
"summaryType") !=
"") {
static RealTime fromString(std::string)
Convert a string as obtained from toString back to a RealTime object.
static void parseIdentifier(QString identifier, QString &type, QString &soName, QString &label)
static QString createIdentifier(QString type, QString soName, QString label)
static QString encodeEntities(QString)
std::string toString(bool align=false) const
Return a human-readable debug-type string to full precision (probably not a format to show to a user ...
RealTime represents time values to nanosecond precision with accurate arithmetic and frame-rate conve...