[89] | 1 | // %pacpus:license{
|
---|
| 2 | // This file is part of the PACPUS framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 4 | // %pacpus:license}
|
---|
| 5 | /// @file
|
---|
| 6 | /// @author Gerald Dherbomez <firstname.surname@utc.fr>
|
---|
| 7 | /// @date January, 2006
|
---|
| 8 | /// @version $Id: XmlConfigFile.h 76 2013-01-10 17:05:10Z kurdejma $
|
---|
| 9 | /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
|
---|
| 10 | /// @brief Brief description.
|
---|
| 11 | ///
|
---|
| 12 | /// Purpose: Classe permettant d'enregistrer un fichier de
|
---|
| 13 | /// configuration XML
|
---|
| 14 | /// Le fichier XML contient 2 sections :
|
---|
| 15 | /// - parameters : contient les parametres de l'application
|
---|
| 16 | /// - components : contient les composants
|
---|
| 17 | /// les composants ne peuvent pas avoir de noeuds fils
|
---|
| 18 | ///
|
---|
| 19 | /// @todo Creer une dtd qui permet de definir la liste des classes possibles
|
---|
| 20 | /// que peuvent prendre les composants
|
---|
| 21 |
|
---|
| 22 | #ifndef DEF_PACPUS_XMLCONFIGFILE_H
|
---|
| 23 | #define DEF_PACPUS_XMLCONFIGFILE_H
|
---|
| 24 |
|
---|
| 25 | #include <Pacpus/kernel/pacpus.h>
|
---|
| 26 | #include <Pacpus/kernel/XmlComponentConfig.h>
|
---|
| 27 |
|
---|
| 28 | #include <QDomElement>
|
---|
[146] | 29 | #include <QFile>
|
---|
[89] | 30 | #include <QMutex>
|
---|
| 31 | #include <QStringList>
|
---|
| 32 |
|
---|
| 33 | class QFile;
|
---|
| 34 |
|
---|
| 35 | namespace pacpus {
|
---|
| 36 |
|
---|
| 37 | /// XML config properties:
|
---|
| 38 | /// list STRING(S) name(s) of plugin files to be loaded, separated by pipe symbol '|'
|
---|
| 39 | /// e.g. dbt="libDbtPlyGps.so|libDbtPlyVision.so
|
---|
| 40 | class PACPUSLIB_API XmlConfigFile
|
---|
| 41 | {
|
---|
| 42 | friend XmlComponentConfig::XmlComponentConfig(const QString&);
|
---|
| 43 | friend class ComponentManager;
|
---|
| 44 |
|
---|
| 45 | public:
|
---|
| 46 | /// @todo Documentation
|
---|
| 47 | static XmlConfigFile * create();
|
---|
| 48 | /// @todo Documentation
|
---|
| 49 | static void destroy();
|
---|
[146] | 50 |
|
---|
[89] | 51 | /// @returns a list of all names of components declared in the XML tree
|
---|
[146] | 52 | QStringList getAllComponentsNames() const;
|
---|
[89] | 53 | /// @todo Documentation
|
---|
[146] | 54 | QDomElement getComponent(QString name) const;
|
---|
| 55 |
|
---|
| 56 | // TODO: QStringList getAllConnectionsNames() const;
|
---|
| 57 | QDomElement getConnection(QString connectionName) const;
|
---|
| 58 |
|
---|
[89] | 59 | /// @todo Documentation
|
---|
[146] | 60 | QStringList getAllPluginsNames();
|
---|
| 61 |
|
---|
| 62 | /// @todo Documentation
|
---|
[89] | 63 | int loadFile(QString fileName);
|
---|
| 64 |
|
---|
| 65 | /// @todo Documentation
|
---|
| 66 | /// not used
|
---|
| 67 | void saveFile(QString fileName);
|
---|
[146] | 68 |
|
---|
[89] | 69 | /// @todo Documentation
|
---|
| 70 | /// not used
|
---|
| 71 | void addComponent(QDomElement component);
|
---|
[146] | 72 |
|
---|
[89] | 73 | /// @todo Documentation
|
---|
[146] | 74 | /// @deprecated Use removeComponent()
|
---|
[89] | 75 | /// not used
|
---|
[146] | 76 | PACPUS_DEPRECATED_MSG( void delComponent(QDomElement component), "use removeComponent()" );
|
---|
| 77 | void removeComponent(QDomElement component);
|
---|
[89] | 78 |
|
---|
| 79 | protected:
|
---|
[165] | 80 | QDomElement getSection(const char * name) const;
|
---|
| 81 | QDomNodeList getNodesInSection(const char * sectionName, const char * nodeName) const;
|
---|
| 82 |
|
---|
[146] | 83 | QDomNodeList getAllComponents() const;
|
---|
| 84 | QDomNodeList getAllConnections() const;
|
---|
[165] | 85 | QDomNodeList getAllParameters() const;
|
---|
[146] | 86 | QDomNodeList getAllPlugins();
|
---|
| 87 |
|
---|
[89] | 88 | private:
|
---|
| 89 | XmlConfigFile();
|
---|
| 90 | ~XmlConfigFile();
|
---|
| 91 |
|
---|
| 92 | QDomElement createComponent(QString name);
|
---|
| 93 |
|
---|
[146] | 94 | QString libraryExtension() const;
|
---|
| 95 | QString libraryPrefix() const;
|
---|
| 96 | QString libraryPostfix() const;
|
---|
| 97 |
|
---|
[89] | 98 | private:
|
---|
[146] | 99 | static XmlConfigFile * m_xmlConfigFile;
|
---|
| 100 |
|
---|
| 101 | QDomDocument m_document;
|
---|
| 102 | QFile m_file;
|
---|
| 103 | QMutex m_mutex;
|
---|
[89] | 104 |
|
---|
[146] | 105 | QString m_libraryExtension;
|
---|
| 106 | QString m_libraryPrefix;
|
---|
| 107 | QString m_libraryPostfix;
|
---|
| 108 |
|
---|
| 109 | int m_numberOfComponents;
|
---|
[89] | 110 | };
|
---|
| 111 |
|
---|
| 112 | } // namespace pacpus
|
---|
| 113 |
|
---|
| 114 | #endif // DEF_PACPUS_XMLCONFIGFILE_H
|
---|