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

Last change on this file since 57 was 31, checked in by sgosseli, 12 years ago

Huge commit: use the new includes style in all the files, add the license header in all the headers, and in some cpp.

File size: 3.3 KB
Line 
1/**
2 *
3 * Distributed under the UTC Heudiascy Pacpus License, Version 1.0.
4 * Copyright (c) UTC Heudiasyc 2010 - 2013. All rights reserved.
5 *
6 * See the LICENSE file for more information or a copy at:
7 * http://www.hds.utc.fr/~kurdejma/LICENSE_1_0.txt
8 *
9 */
10
11#ifndef DEF_PACPUS_XMLCOMPONENTCONFIG_H
12#define DEF_PACPUS_XMLCOMPONENTCONFIG_H
13
14#include <Pacpus/kernel/pacpus.h>
15
16#include <QDomElement>
17
18namespace pacpus {
19
20class XmlConfigFile;
21
22/** XmlComponentConfig
23 * @brief Defines the XML structure of a component.
24 */
25class PACPUSLIB_API XmlComponentConfig
26{
27 friend class ComponentManager;
28public:
29 /** Ctor of XmlComponentConfig.
30 * @param name Name of the ComponentFactory, by convention equal to class name.
31 */
32 explicit XmlComponentConfig(const QString& name = QString::null);
33
34 /** Dtor of XmlComponentConfig. */
35 ~XmlComponentConfig();
36
37 /** Add the property @em name to the XML and set its value to @em 0 if it does not exist.
38 * @param name Name of the property.
39 */
40 void addProperty(const QString& name);
41
42 /** Delete a property from the XML.
43 * @return False if the property does not exist, false otherwise.
44 */
45 int delProperty(const QString& name);
46
47 /** Get the value of a property.
48 * @param name Name of the property.
49 * @param defaultValue Value returned if the property does not exist.
50 * @return Value of the property, @em defaultValue otherwise.
51 */
52 QString getProperty(const QString& name, const QString& defaultValue = QString::null) const;
53
54 /** Get the value of a property as a boolean.
55 * @param name Name of the property.
56 * @param defaultValue Value returned if the property does not exist.
57 * @return Value of the property, @em defaultValue otherwise.
58 */
59 int getBoolProperty(const QString& name, bool defaultValue = false) const;
60
61 /** Get the value of a property as an integer.
62 * @param name Name of the property.
63 * @param defaultValue Value returned if the property does not exist.
64 * @return Value of the property, @em defaultValue otherwise.
65 */
66 int getIntProperty(const QString& name, int defaultValue = 0) const;
67
68 /** Get the value of a property as a double.
69 * @param name Name of the property.
70 * @param defaultValue Value returned if the property does not exist.
71 * @return Value of the property, @em defaultValue otherwise.
72 */
73 int getDoubleProperty(const QString& name, double defaultValue = 0.0) const;
74
75 /** Set the value of a property.
76 * @param name Name of the property.
77 * @param value Value to set.
78 */
79 void setProperty(const QString& name, const QString& value);
80
81 /** Check if a property exists.
82 * @param name Name of the property.
83 * @return True if the property exists, false otherwise.
84 */
85 bool hasProperty(const QString& name) const;
86
87private:
88 // Returns the local QDomElement.
89 QDomElement qDomElement() const;
90
91 // Copy internally the node in the internal QDomElement.
92 void localCopy(const QDomElement& elementToCopy);
93
94 QString const getComponentName() const;
95 QString const getComponentType() const;
96
97private:
98 QDomElement component_;
99 XmlConfigFile * parentDocument_;
100};
101
102} // namespace pacpus
103
104#endif // DEF_PACPUS_XMLCOMPONENTCONFIG_H
Note: See TracBrowser for help on using the repository browser.