source: pacpusframework/trunk/include/Pacpus/kernel/XmlComponentConfig.h@ 23

Last change on this file since 23 was 3, checked in by sgosseli, 12 years ago
  • Add the existing Pacpus files from pacpusdev and pacpuscore.
  • Provide a clean build system based on multiple CMake files.
File size: 3.4 KB
Line 
1/*********************************************************************
2//
3// created: 2006/01/30 - 10:58
4//
5// filename: xmlcomponentconfig.h
6//
7// author: Gerald Dherbomez
8//
9// purpose: definit la structure XML des paramètres de configuration
10// d'un composant
11*********************************************************************/
12
13#ifndef XMLCOMPONENTCONFIG_H
14#define XMLCOMPONENTCONFIG_H
15
16#include "pacpus.h"
17
18#include <QDomElement>
19
20namespace pacpus {
21
22class XmlConfigFile;
23
24/** XmlComponentConfig
25 * @brief Defines the XML structure of a component.
26 */
27class PACPUSLIB_API XmlComponentConfig
28{
29 friend class ComponentManager;
30public:
31 /** Ctor of XmlComponentConfig.
32 * @param name Name of the ComponentFactory, by convention equal to class name.
33 */
34 explicit XmlComponentConfig(const QString& name = QString::null);
35
36 /** Dtor of XmlComponentConfig. */
37 ~XmlComponentConfig();
38
39 /** Add the property @em name to the XML and set its value to @em 0 if it does not exist.
40 * @param name Name of the property.
41 */
42 void addProperty(const QString& name);
43
44 /** Delete a property from the XML.
45 * @return False if the property does not exist, false otherwise.
46 */
47 int delProperty(const QString& name);
48
49 /** Get the value of a property.
50 * @param name Name of the property.
51 * @param defaultValue Value returned if the property does not exist.
52 * @return Value of the property, @em defaultValue otherwise.
53 */
54 QString getProperty(const QString& name, const QString& defaultValue = QString::null) const;
55
56 /** Get the value of a property as a boolean.
57 * @param name Name of the property.
58 * @param defaultValue Value returned if the property does not exist.
59 * @return Value of the property, @em defaultValue otherwise.
60 */
61 int getBoolProperty(const QString& name, bool defaultValue = false) const;
62
63 /** Get the value of a property as an integer.
64 * @param name Name of the property.
65 * @param defaultValue Value returned if the property does not exist.
66 * @return Value of the property, @em defaultValue otherwise.
67 */
68 int getIntProperty(const QString& name, int defaultValue = 0) const;
69
70 /** Get the value of a property as a double.
71 * @param name Name of the property.
72 * @param defaultValue Value returned if the property does not exist.
73 * @return Value of the property, @em defaultValue otherwise.
74 */
75 int getDoubleProperty(const QString& name, double defaultValue = 0.0) const;
76
77 /** Set the value of a property.
78 * @param name Name of the property.
79 * @param value Value to set.
80 */
81 void setProperty(const QString& name, const QString& value);
82
83 /** Check if a property exists.
84 * @param name Name of the property.
85 * @return True if the property exists, false otherwise.
86 */
87 bool hasProperty(const QString& name) const;
88
89private:
90 // Returns the local QDomElement.
91 QDomElement qDomElement() const;
92
93 // Copy internally the node in the internal QDomElement.
94 void localCopy(const QDomElement& elementToCopy);
95
96 QString const getComponentName() const;
97 QString const getComponentType() const;
98
99private:
100 QDomElement component_;
101 XmlConfigFile * parentDocument_;
102};
103
104} // namespace pacpus
105
106#endif // XMLCOMPONENTCONFIG_H
Note: See TracBrowser for help on using the repository browser.