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

Last change on this file since 62 was 62, checked in by Marek Kurdej, 12 years ago

Update: license info.

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