bool Scene::loadXML(QDomDocument* doc, QDomElement* root) { t_value value = 0; t_channel ch = 0; Scene::ValueType value_type; QString str; QDomNode node; QDomElement tag; Q_ASSERT(doc != NULL); Q_ASSERT(root != NULL); if (root->tagName() != KXMLQLCFunction) { qWarning("Function node not found!"); return false; } /* Load scene contents */ node = root->firstChild(); while (node.isNull() == false) { tag = node.toElement(); if (tag.tagName() == KXMLQLCBus) { /* Bus */ str = tag.attribute(KXMLQLCBusRole); Q_ASSERT(str == KXMLQLCBusFade); Q_ASSERT(setBus(tag.text().toInt()) == true); } else if (tag.tagName() == KXMLQLCFunctionValue) { /* Channel value */ str = tag.attribute(KXMLQLCFunctionValueType); value_type = stringToValueType(str); ch = tag.attribute(KXMLQLCFunctionChannel).toInt(); value = tag.text().toInt(); Q_ASSERT(set(ch, value, value_type) == true); } else qWarning("Unknown scene tag: %s", (const char*) tag.tagName()); node = node.nextSibling(); } return true; }
bool ConfigTree::paramFromPtree(ptree fromPtree, ConfigParameter &toParam) { CONFIGSYS_DEBUG_CALLS; std::string typStr = fromPtree.get<std::string>("type"); value_type vt = stringToValueType(typStr); toParam = ConfigParameter(vt); toParam.setDescription(fromPtree.get("desc", "")); std::string modStr = fromPtree.get("modified", "false"); toParam.setModified(modStr.compare("true") == 0); std::string lockStr = fromPtree.get("locked", "false"); toParam.setLocked(lockStr.compare("true") == 0); return addPtreeValueandRangeToParam(fromPtree, toParam); }
bool ConfigTree::addPtreeValueandRangeToParam(ptree fromPtree, ConfigParameter &toParam) { CONFIGSYS_DEBUG_CALLS; std::string typStr = fromPtree.get<std::string>("type"); value_type vt = stringToValueType(typStr); // std::cout << "ConfigTree::addPtreeValueandRangeToParam(...): vt = " // << makeValueTypeString(vt) << std::endl; bool success_v = false; bool success_r = true ; switch(vt) { case vt_string: success_v = addValueToParam<std::string>(fromPtree, toParam); break; case vt_double: success_v = addValueToParam<double>(fromPtree, toParam); break; case vt_bool: success_v = addValueToParam<bool>(fromPtree, toParam); break; case vt_long: success_v = addValueToParam<long>(fromPtree, toParam); break; case vt_1dvector_double: success_v = addVectorValueToParam1D<double>(fromPtree, toParam); break; case vt_2dvector_double: success_v = addVectorValueToParam2D<double>(fromPtree, toParam); break; case vt_3dvector_double: success_v = addVectorValueToParam3D<double>(fromPtree, toParam); break; case vt_1dvector_long: success_v = addVectorValueToParam1D<long>(fromPtree, toParam); break; case vt_2dvector_long: success_v = addVectorValueToParam2D<long>(fromPtree, toParam); break; case vt_3dvector_long: success_v = addVectorValueToParam3D<long>(fromPtree, toParam); break; default: std::cerr << __PRETTY_FUNCTION__ << ": Invalid val_type" << makeValueTypeString(vt) << "'" << "'" << std::endl; break; } switch(vt) { //cases fall through as they use the same - change later if necessary. case vt_string : // Strings can't have ranges break; case vt_double : case vt_1dvector_double: case vt_2dvector_double: case vt_3dvector_double: success_r = addRangeToParam<double>(fromPtree, toParam); break; case vt_bool : case vt_long : case vt_1dvector_long: case vt_2dvector_long: case vt_3dvector_long: success_r = addRangeToParam<long>(fromPtree, toParam); break; default: std::cerr << __PRETTY_FUNCTION__ << ": Invalid val_type" << makeValueTypeString(vt) << std::endl; break; } // std::cout << __PRETTY_FUNCTION__ << ": success_v = " << success_v << std::endl; // std::cout << __PRETTY_FUNCTION__ << ": success_r = " << success_r << std::endl; // std::cout << __PRETTY_FUNCTION__ << ( (success_r)? ": success" : ": failed" ) << std::endl; return success_v && success_r; }