[62] | 1 | // This file is part of the PACPUS framework distributed under the
|
---|
| 2 | // CECILL-C License, Version 1.0.
|
---|
| 3 | //
|
---|
[66] | 4 | /// @file
|
---|
[63] | 5 | /// @author Gerald Dherbomez <firstname.surname@utc.fr>
|
---|
| 6 | /// @date January, 2006
|
---|
[62] | 7 | /// @version $Id: XmlComponentConfig.h 66 2013-01-09 16:54:11Z kurdejma $
|
---|
| 8 | /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
|
---|
| 9 | /// @brief Brief description.
|
---|
| 10 | ///
|
---|
[63] | 11 | /// Purpose: definit la structure XML des paramètres de configuration
|
---|
| 12 | /// d'un composant
|
---|
[3] | 13 |
|
---|
[31] | 14 | #ifndef DEF_PACPUS_XMLCOMPONENTCONFIG_H
|
---|
| 15 | #define DEF_PACPUS_XMLCOMPONENTCONFIG_H
|
---|
[3] | 16 |
|
---|
[31] | 17 | #include <Pacpus/kernel/pacpus.h>
|
---|
[3] | 18 |
|
---|
| 19 | #include <QDomElement>
|
---|
| 20 |
|
---|
| 21 | namespace pacpus {
|
---|
| 22 |
|
---|
| 23 | class XmlConfigFile;
|
---|
| 24 |
|
---|
| 25 | /** XmlComponentConfig
|
---|
| 26 | * @brief Defines the XML structure of a component.
|
---|
| 27 | */
|
---|
| 28 | class PACPUSLIB_API XmlComponentConfig
|
---|
| 29 | {
|
---|
| 30 | friend class ComponentManager;
|
---|
| 31 | public:
|
---|
| 32 | /** Ctor of XmlComponentConfig.
|
---|
| 33 | * @param name Name of the ComponentFactory, by convention equal to class name.
|
---|
| 34 | */
|
---|
| 35 | explicit XmlComponentConfig(const QString& name = QString::null);
|
---|
| 36 |
|
---|
| 37 | /** Dtor of XmlComponentConfig. */
|
---|
| 38 | ~XmlComponentConfig();
|
---|
| 39 |
|
---|
| 40 | /** Add the property @em name to the XML and set its value to @em 0 if it does not exist.
|
---|
| 41 | * @param name Name of the property.
|
---|
| 42 | */
|
---|
| 43 | void addProperty(const QString& name);
|
---|
| 44 |
|
---|
| 45 | /** Delete a property from the XML.
|
---|
| 46 | * @return False if the property does not exist, false otherwise.
|
---|
| 47 | */
|
---|
| 48 | int delProperty(const QString& name);
|
---|
| 49 |
|
---|
| 50 | /** Get the value of a property.
|
---|
| 51 | * @param name Name of the property.
|
---|
| 52 | * @param defaultValue Value returned if the property does not exist.
|
---|
| 53 | * @return Value of the property, @em defaultValue otherwise.
|
---|
| 54 | */
|
---|
| 55 | QString getProperty(const QString& name, const QString& defaultValue = QString::null) const;
|
---|
| 56 |
|
---|
| 57 | /** Get the value of a property as a boolean.
|
---|
| 58 | * @param name Name of the property.
|
---|
| 59 | * @param defaultValue Value returned if the property does not exist.
|
---|
| 60 | * @return Value of the property, @em defaultValue otherwise.
|
---|
| 61 | */
|
---|
| 62 | int getBoolProperty(const QString& name, bool defaultValue = false) const;
|
---|
| 63 |
|
---|
| 64 | /** Get the value of a property as an integer.
|
---|
| 65 | * @param name Name of the property.
|
---|
| 66 | * @param defaultValue Value returned if the property does not exist.
|
---|
| 67 | * @return Value of the property, @em defaultValue otherwise.
|
---|
| 68 | */
|
---|
| 69 | int getIntProperty(const QString& name, int defaultValue = 0) const;
|
---|
| 70 |
|
---|
| 71 | /** Get the value of a property as a double.
|
---|
| 72 | * @param name Name of the property.
|
---|
| 73 | * @param defaultValue Value returned if the property does not exist.
|
---|
| 74 | * @return Value of the property, @em defaultValue otherwise.
|
---|
| 75 | */
|
---|
| 76 | int getDoubleProperty(const QString& name, double defaultValue = 0.0) const;
|
---|
| 77 |
|
---|
| 78 | /** Set the value of a property.
|
---|
| 79 | * @param name Name of the property.
|
---|
| 80 | * @param value Value to set.
|
---|
| 81 | */
|
---|
| 82 | void setProperty(const QString& name, const QString& value);
|
---|
| 83 |
|
---|
| 84 | /** Check if a property exists.
|
---|
| 85 | * @param name Name of the property.
|
---|
| 86 | * @return True if the property exists, false otherwise.
|
---|
| 87 | */
|
---|
| 88 | bool hasProperty(const QString& name) const;
|
---|
| 89 |
|
---|
| 90 | private:
|
---|
| 91 | // Returns the local QDomElement.
|
---|
| 92 | QDomElement qDomElement() const;
|
---|
| 93 |
|
---|
| 94 | // Copy internally the node in the internal QDomElement.
|
---|
| 95 | void localCopy(const QDomElement& elementToCopy);
|
---|
| 96 |
|
---|
| 97 | QString const getComponentName() const;
|
---|
| 98 | QString const getComponentType() const;
|
---|
| 99 |
|
---|
| 100 | private:
|
---|
| 101 | QDomElement component_;
|
---|
| 102 | XmlConfigFile * parentDocument_;
|
---|
| 103 | };
|
---|
| 104 |
|
---|
| 105 | } // namespace pacpus
|
---|
| 106 |
|
---|
[31] | 107 | #endif // DEF_PACPUS_XMLCOMPONENTCONFIG_H
|
---|