| 1 | // This file is part of the PACPUS framework distributed under the
 | 
|---|
| 2 | // CECILL-C License, Version 1.0.
 | 
|---|
| 3 | // 
 | 
|---|
| 4 | /// @author  Gerald Dherbomez <firstname.surname@utc.fr>
 | 
|---|
| 5 | /// @date    January, 2006
 | 
|---|
| 6 | /// @version $Id$
 | 
|---|
| 7 | /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
 | 
|---|
| 8 | /// @brief Brief description.
 | 
|---|
| 9 | ///
 | 
|---|
| 10 | /// Purpose:    Classe permettant d'enregistrer un fichier de 
 | 
|---|
| 11 | ///             configuration XML
 | 
|---|
| 12 | ///             Le fichier XML contient 2 sections : 
 | 
|---|
| 13 | ///             - parameters : contient les parametres de l'application 
 | 
|---|
| 14 | ///             - components : contient les composants
 | 
|---|
| 15 | ///             les composants ne peuvent pas avoir de noeuds fils
 | 
|---|
| 16 | ///
 | 
|---|
| 17 | /// @todo       Creer une dtd qui permet de definir la liste des classes possibles
 | 
|---|
| 18 | ///             que peuvent prendre les composants 
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #ifndef DEF_PACPUS_XMLCONFIGFILE_H
 | 
|---|
| 21 | #define DEF_PACPUS_XMLCONFIGFILE_H
 | 
|---|
| 22 | 
 | 
|---|
| 23 | #include <Pacpus/kernel/pacpus.h>
 | 
|---|
| 24 | #include <Pacpus/kernel/XmlComponentConfig.h>
 | 
|---|
| 25 | 
 | 
|---|
| 26 | #include <QDomElement>
 | 
|---|
| 27 | #include <QMutex>
 | 
|---|
| 28 | #include <QStringList>
 | 
|---|
| 29 | 
 | 
|---|
| 30 | class QFile;
 | 
|---|
| 31 | 
 | 
|---|
| 32 | namespace pacpus {
 | 
|---|
| 33 | 
 | 
|---|
| 34 | /// XML config properties:
 | 
|---|
| 35 | ///     list            STRING(S)   name(s) of plugin files to be loaded, separated by pipe symbol '|'
 | 
|---|
| 36 | ///         e.g. dbt="libDbtPlyGps.so|libDbtPlyVision.so
 | 
|---|
| 37 | class PACPUSLIB_API XmlConfigFile
 | 
|---|
| 38 | {
 | 
|---|
| 39 |     friend XmlComponentConfig::XmlComponentConfig(const QString&);
 | 
|---|
| 40 |     friend class ComponentManager;
 | 
|---|
| 41 | 
 | 
|---|
| 42 | public:
 | 
|---|
| 43 |     /// @todo Documentation
 | 
|---|
| 44 |     static XmlConfigFile * create();
 | 
|---|
| 45 |     /// @todo Documentation
 | 
|---|
| 46 |     static void destroy();
 | 
|---|
| 47 |     /// @todo Documentation
 | 
|---|
| 48 |     QDomElement getComponent(QString name);
 | 
|---|
| 49 |     /// @returns a list of all names of components declared in the XML tree
 | 
|---|
| 50 |     QStringList getAllComponents();
 | 
|---|
| 51 |     /// @todo Documentation
 | 
|---|
| 52 |     QStringList getAllPlugins();
 | 
|---|
| 53 |     /// @todo Documentation
 | 
|---|
| 54 |     int loadFile(QString fileName);
 | 
|---|
| 55 | 
 | 
|---|
| 56 |     /// @todo Documentation
 | 
|---|
| 57 |     /// not used
 | 
|---|
| 58 |     void saveFile(QString fileName);
 | 
|---|
| 59 |     /// @todo Documentation
 | 
|---|
| 60 |     /// not used
 | 
|---|
| 61 |     void addComponent(QDomElement component);
 | 
|---|
| 62 |     /// @todo Documentation
 | 
|---|
| 63 |     /// not used
 | 
|---|
| 64 |     void delComponent(QDomElement component);
 | 
|---|
| 65 | 
 | 
|---|
| 66 | protected:
 | 
|---|
| 67 | private:
 | 
|---|
| 68 |     XmlConfigFile();
 | 
|---|
| 69 |     ~XmlConfigFile();
 | 
|---|
| 70 | 
 | 
|---|
| 71 |     static XmlConfigFile * _xmlConfigFile;
 | 
|---|
| 72 |     
 | 
|---|
| 73 |     QDomElement createComponent(QString name);
 | 
|---|
| 74 | 
 | 
|---|
| 75 | private:
 | 
|---|
| 76 |     QDomDocument _document;
 | 
|---|
| 77 |     QFile * _file;
 | 
|---|
| 78 |     QMutex _mutex;
 | 
|---|
| 79 | 
 | 
|---|
| 80 |     int _numberOfComponents;
 | 
|---|
| 81 | };
 | 
|---|
| 82 | 
 | 
|---|
| 83 | } // namespace pacpus
 | 
|---|
| 84 | 
 | 
|---|
| 85 | #endif // DEF_PACPUS_XMLCONFIGFILE_H
 | 
|---|