Changeset 165 in pacpusframework for branches/2.0-beta1/src/PacpusLib/XmlConfigFile.cpp
- Timestamp:
- Aug 1, 2013, 6:30:31 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0-beta1/src/PacpusLib/XmlConfigFile.cpp
r147 r165 28 28 static const char * kConnectionSection = "connections"; 29 29 static const char * kParameterSection = "parameters"; 30 static const char * kPluginSection = "plugins"; 30 31 31 32 static const char * kComponentNode = "component"; 32 33 static const char * kConnectionNode = "connection"; 34 static const char * kParameterNode = "parameter"; 33 35 static const char * kPluginNode = "plugin"; 34 36 … … 55 57 // create the sections 56 58 m_document.documentElement().appendChild(m_document.createElement(kParameterSection)); 59 m_document.documentElement().appendChild(m_document.createElement(kPluginSection)); 57 60 m_document.documentElement().appendChild(m_document.createElement(kComponentSection)); 58 61 m_document.documentElement().appendChild(m_document.createElement(kConnectionSection)); … … 93 96 (void) mutexLocker; // unused 94 97 95 // TODO: change .tagName => .attribute(kPropertyComponentName .c_str())98 // TODO: change .tagName => .attribute(kPropertyComponentName) 96 99 QDomNode componentSectionNode = getNamedItemFromDomDocument(m_document, kComponentSection); 97 100 if (componentSectionNode.namedItem(component.attribute(kNameAttribute)/*.tagName()*/).isNull()) { … … 206 209 } 207 210 211 // XML 212 QDomElement XmlConfigFile::getSection(const char * name) const 213 { 214 QDomElement sectionElement = getNamedItemFromDomDocument(m_document, name).toElement(); 215 if (sectionElement.isNull()) { 216 LOG_WARN("there is no '" << name << "' section in the XML"); 217 return QDomElement(); 218 } 219 return sectionElement; 220 } 221 222 QDomNodeList XmlConfigFile::getNodesInSection(const char * sectionName, const char * nodeName) const 223 { 224 QDomElement sectionElement = getSection(sectionName); 225 return sectionElement.elementsByTagName(nodeName); 226 } 227 208 228 // COMPONENTS 209 229 QDomNodeList XmlConfigFile::getAllComponents() const 210 230 { 211 // get components section 212 QDomElement componentsElement = getNamedItemFromDomDocument(m_document, kComponentSection).toElement(); 213 if (componentsElement.isNull()) { 214 LOG_WARN("there is no '" << kComponentSection << "' section in the XML"); 215 return QDomNodeList(); 216 } 217 218 // get component nodes 219 return componentsElement.elementsByTagName(kComponentNode); 231 return getNodesInSection(kComponentSection, kComponentNode); 220 232 } 221 233 … … 252 264 QDomNodeList XmlConfigFile::getAllConnections() const 253 265 { 254 // get connections section 255 QDomElement connectionsElement = getNamedItemFromDomDocument(m_document, kParameterSection).toElement(); 256 if (connectionsElement.isNull()) { 257 LOG_WARN("there is no '" << kParameterSection << "' section in the XML"); 258 return QDomNodeList(); 259 } 260 261 // get connection nodes 262 //return connectionsElement.elementsByTagName(kConnectionNode); 263 return getNamedItemFromDomDocument(m_document, kConnectionSection).childNodes(); 266 return getNodesInSection(kConnectionSection, kConnectionNode); 264 267 } 265 268 … … 281 284 } 282 285 286 // PARAMETERS 287 QDomNodeList XmlConfigFile::getAllParameters() const 288 { 289 return getNodesInSection(kParameterSection, kParameterNode); 290 } 291 283 292 // PLUGINS 284 293 QDomNodeList XmlConfigFile::getAllPlugins() 285 294 { 286 // get parameters section 287 QDomElement parametersElement = getNamedItemFromDomDocument(m_document, kParameterSection).toElement(); 288 if (parametersElement.isNull()) { 289 LOG_WARN("there is no '" << kParameterSection << "' section in the XML"); 290 return QDomNodeList(); 291 } 295 // get section 296 QDomElement pluginsElement = getSection(kPluginSection); 292 297 293 298 // get attributes 294 m_libraryExtension = p arametersElement.attribute(kExtensionAttribute);299 m_libraryExtension = pluginsElement.attribute(kExtensionAttribute); 295 300 if (!m_libraryExtension.isEmpty()) { 296 301 // prefix with a dot '.' if there is no one … … 299 304 } 300 305 } 301 m_libraryPrefix = p arametersElement.attribute(kPrefixAttribute);302 m_libraryPostfix = p arametersElement.attribute(kPostfixAttribute);306 m_libraryPrefix = pluginsElement.attribute(kPrefixAttribute); 307 m_libraryPostfix = pluginsElement.attribute(kPostfixAttribute); 303 308 304 // get pluginnodes305 return parametersElement.elementsByTagName(kPluginNode);309 // get nodes 310 return getNodesInSection(kPluginSection, kPluginNode); 306 311 } 307 312 … … 313 318 return QStringList(); 314 319 } 320 LOG_INFO("there are " << pluginList.size() << " plugins"); 315 321 316 322 // get plugin library paths
Note:
See TracChangeset
for help on using the changeset viewer.