Changeset 165 in pacpusframework for branches/2.0-beta1/src/PacpusLib/XmlConfigFile.cpp


Ignore:
Timestamp:
08/01/13 18:30:31 (11 years ago)
Author:
Marek Kurdej
Message:

Major: changed plugins section name to plugings. Parameters section will be used for something else.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0-beta1/src/PacpusLib/XmlConfigFile.cpp

    r147 r165  
    2828static const char * kConnectionSection = "connections";
    2929static const char * kParameterSection = "parameters";
     30static const char * kPluginSection = "plugins";
    3031
    3132static const char * kComponentNode = "component";
    3233static const char * kConnectionNode = "connection";
     34static const char * kParameterNode = "parameter";
    3335static const char * kPluginNode = "plugin";
    3436
     
    5557    // create the sections
    5658    m_document.documentElement().appendChild(m_document.createElement(kParameterSection));
     59    m_document.documentElement().appendChild(m_document.createElement(kPluginSection));
    5760    m_document.documentElement().appendChild(m_document.createElement(kComponentSection));
    5861    m_document.documentElement().appendChild(m_document.createElement(kConnectionSection));
     
    9396    (void) mutexLocker; // unused
    9497
    95     // TODO: change .tagName => .attribute(kPropertyComponentName.c_str())
     98    // TODO: change .tagName => .attribute(kPropertyComponentName)
    9699    QDomNode componentSectionNode = getNamedItemFromDomDocument(m_document, kComponentSection);
    97100    if (componentSectionNode.namedItem(component.attribute(kNameAttribute)/*.tagName()*/).isNull()) {
     
    206209}
    207210
     211// XML
     212QDomElement 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
     222QDomNodeList XmlConfigFile::getNodesInSection(const char * sectionName, const char * nodeName) const
     223{
     224    QDomElement sectionElement = getSection(sectionName);
     225    return sectionElement.elementsByTagName(nodeName);
     226}
     227
    208228// COMPONENTS
    209229QDomNodeList XmlConfigFile::getAllComponents() const
    210230{
    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);
    220232}
    221233
     
    252264QDomNodeList XmlConfigFile::getAllConnections() const
    253265{
    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);
    264267}
    265268
     
    281284}
    282285
     286// PARAMETERS
     287QDomNodeList XmlConfigFile::getAllParameters() const
     288{
     289    return getNodesInSection(kParameterSection, kParameterNode);
     290}
     291
    283292// PLUGINS
    284293QDomNodeList XmlConfigFile::getAllPlugins()
    285294{
    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);
    292297
    293298    // get attributes
    294     m_libraryExtension = parametersElement.attribute(kExtensionAttribute);
     299    m_libraryExtension = pluginsElement.attribute(kExtensionAttribute);
    295300    if (!m_libraryExtension.isEmpty()) {
    296301        // prefix with a dot '.' if there is no one
     
    299304        }
    300305    }
    301     m_libraryPrefix = parametersElement.attribute(kPrefixAttribute);
    302     m_libraryPostfix = parametersElement.attribute(kPostfixAttribute);
     306    m_libraryPrefix = pluginsElement.attribute(kPrefixAttribute);
     307    m_libraryPostfix = pluginsElement.attribute(kPostfixAttribute);
    303308   
    304     // get plugin nodes
    305     return parametersElement.elementsByTagName(kPluginNode);
     309    // get nodes
     310    return getNodesInSection(kPluginSection, kPluginNode);
    306311}
    307312
     
    313318        return QStringList();
    314319    }
     320    LOG_INFO("there are " << pluginList.size() << " plugins");
    315321
    316322    // get plugin library paths
Note: See TracChangeset for help on using the changeset viewer.