[79] | 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: XmlComponentConfig.h 91 2013-05-19 10:32:48Z gdherbom $
|
---|
| 9 | /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
|
---|
| 10 | /// @brief Brief description.
|
---|
| 11 | ///
|
---|
[91] | 12 | /// Purpose: This class manages a XML node corresponding to a PACPUS component.
|
---|
[3] | 13 |
|
---|
[79] | 14 | #ifndef DEF_PACPUS_XMLCOMPONENTCONFIG_H
|
---|
| 15 | #define DEF_PACPUS_XMLCOMPONENTCONFIG_H
|
---|
[3] | 16 |
|
---|
[79] | 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 | */
|
---|
[78] | 62 | bool getBoolProperty(const QString& name, bool defaultValue = false) const;
|
---|
[3] | 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 | */
|
---|
[78] | 76 | double getDoubleProperty(const QString& name, double defaultValue = 0.0) const;
|
---|
[3] | 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 |
|
---|
[79] | 107 | #endif // DEF_PACPUS_XMLCOMPONENTCONFIG_H
|
---|