[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
|
---|
[288] | 24 |
|
---|
| 25 | #include <Pacpus/kernel/pacpus.h>
|
---|
[197] | 26 | #include <Pacpus/kernel/PacpusLibConfig.h>
|
---|
[89] | 27 | #include <Pacpus/kernel/XmlComponentConfig.h>
|
---|
| 28 |
|
---|
| 29 | #include <QDomElement>
|
---|
[146] | 30 | #include <QFile>
|
---|
[89] | 31 | #include <QMutex>
|
---|
| 32 | #include <QStringList>
|
---|
| 33 |
|
---|
| 34 | class QFile;
|
---|
| 35 |
|
---|
| 36 | namespace pacpus {
|
---|
| 37 |
|
---|
| 38 | /// XML config properties:
|
---|
| 39 | /// list STRING(S) name(s) of plugin files to be loaded, separated by pipe symbol '|'
|
---|
| 40 | /// e.g. dbt="libDbtPlyGps.so|libDbtPlyVision.so
|
---|
| 41 | class PACPUSLIB_API XmlConfigFile
|
---|
| 42 | {
|
---|
[288] | 43 | friend XmlComponentConfig::XmlComponentConfig(QString const&);
|
---|
[89] | 44 | friend class ComponentManager;
|
---|
| 45 |
|
---|
| 46 | public:
|
---|
| 47 | /// @todo Documentation
|
---|
| 48 | static XmlConfigFile * create();
|
---|
| 49 | /// @todo Documentation
|
---|
| 50 | static void destroy();
|
---|
[146] | 51 |
|
---|
[89] | 52 | /// @returns a list of all names of components declared in the XML tree
|
---|
[146] | 53 | QStringList getAllComponentsNames() const;
|
---|
[89] | 54 | /// @todo Documentation
|
---|
[146] | 55 | QDomElement getComponent(QString name) const;
|
---|
| 56 |
|
---|
| 57 | // TODO: QStringList getAllConnectionsNames() const;
|
---|
| 58 | QDomElement getConnection(QString connectionName) const;
|
---|
| 59 |
|
---|
[89] | 60 | /// @todo Documentation
|
---|
[146] | 61 | QStringList getAllPluginsNames();
|
---|
| 62 |
|
---|
| 63 | /// @todo Documentation
|
---|
[89] | 64 | int loadFile(QString fileName);
|
---|
| 65 |
|
---|
| 66 | /// @todo Documentation
|
---|
| 67 | /// not used
|
---|
| 68 | void saveFile(QString fileName);
|
---|
[146] | 69 |
|
---|
[89] | 70 | /// @todo Documentation
|
---|
| 71 | /// not used
|
---|
| 72 | void addComponent(QDomElement component);
|
---|
[146] | 73 |
|
---|
[89] | 74 | /// @todo Documentation
|
---|
[146] | 75 | /// @deprecated Use removeComponent()
|
---|
[89] | 76 | /// not used
|
---|
[146] | 77 | PACPUS_DEPRECATED_MSG( void delComponent(QDomElement component), "use removeComponent()" );
|
---|
| 78 | void removeComponent(QDomElement component);
|
---|
[89] | 79 |
|
---|
| 80 | protected:
|
---|
[165] | 81 | QDomElement getSection(const char * name) const;
|
---|
| 82 | QDomNodeList getNodesInSection(const char * sectionName, const char * nodeName) const;
|
---|
| 83 |
|
---|
[146] | 84 | QDomNodeList getAllComponents() const;
|
---|
| 85 | QDomNodeList getAllConnections() const;
|
---|
[165] | 86 | QDomNodeList getAllParameters() const;
|
---|
[146] | 87 | QDomNodeList getAllPlugins();
|
---|
| 88 |
|
---|
[89] | 89 | private:
|
---|
| 90 | XmlConfigFile();
|
---|
| 91 | ~XmlConfigFile();
|
---|
| 92 |
|
---|
| 93 | QDomElement createComponent(QString name);
|
---|
| 94 |
|
---|
[146] | 95 | QString libraryExtension() const;
|
---|
| 96 | QString libraryPrefix() const;
|
---|
| 97 | QString libraryPostfix() const;
|
---|
| 98 |
|
---|
[89] | 99 | private:
|
---|
[146] | 100 | static XmlConfigFile * m_xmlConfigFile;
|
---|
| 101 |
|
---|
| 102 | QDomDocument m_document;
|
---|
| 103 | QFile m_file;
|
---|
| 104 | QMutex m_mutex;
|
---|
[89] | 105 |
|
---|
[146] | 106 | QString m_libraryExtension;
|
---|
| 107 | QString m_libraryPrefix;
|
---|
| 108 | QString m_libraryPostfix;
|
---|
| 109 |
|
---|
| 110 | int m_numberOfComponents;
|
---|
[89] | 111 | };
|
---|
| 112 |
|
---|
| 113 | } // namespace pacpus
|
---|
| 114 |
|
---|
| 115 | #endif // DEF_PACPUS_XMLCONFIGFILE_H
|
---|