source: pacpusframework/branches/0.0.x/include/Pacpus/kernel/XmlComponentConfig.h

Last change on this file was 116, checked in by Marek Kurdej, 11 years ago

Added: PacpusException - base class for all exceptions. DbiteExceptions inherits from it.
Added: PacpusLibConfig.h - dllimport/dllexport clauses separated from pacpus.h.
Update: comments.

  • Property svn:keywords set to Id
File size: 3.6 KB
Line 
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 116 2013-06-25 11:44:25Z kurdejma $
9/// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
10/// @brief Brief description.
11///
12/// Purpose: This class manages a XML node corresponding to a PACPUS component.
13
14#ifndef DEF_PACPUS_XMLCOMPONENTCONFIG_H
15#define DEF_PACPUS_XMLCOMPONENTCONFIG_H
16
17#include <Pacpus/kernel/PacpusLibConfig.h>
18
19#include <QDomElement>
20
21namespace pacpus {
22
23class XmlConfigFile;
24
25/// XmlComponentConfig
26/// @brief Defines the XML structure of a component.
27class PACPUSLIB_API XmlComponentConfig
28{
29 friend class ComponentManager;
30
31public:
32 /// Ctor of XmlComponentConfig.
33 /// @param name Name of the ComponentFactory, by convention equal to class name.
34 explicit XmlComponentConfig(const QString & name = QString::null);
35
36 /// Dtor of XmlComponentConfig.
37 ~XmlComponentConfig();
38
39 /// Adds 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 void addProperty(const QString& name);
42
43 /// Deletes property @em name from the XML.
44 ///
45 /// @returns @b true if the property existed and was removed, @b false if the property did not exist or could not be removed.
46 int delProperty(const QString& name);
47
48 /// Gets 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 QString getProperty(const QString& name, const QString& defaultValue = QString::null) const;
53
54 /// Gets 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 /// @returns Value of the property, @em defaultValue otherwise.
58 bool getBoolProperty(const QString& name, bool defaultValue = false) const;
59
60 /// Get the value of a property as an integer.
61 /// @param name Name of the property.
62 /// @param defaultValue Value returned if the property does not exist.
63 /// @return Value of the property, @em defaultValue otherwise.
64 int getIntProperty(const QString& name, int defaultValue = 0) const;
65
66 /// Get the value of a property as a double.
67 /// @param name Name of the property.
68 /// @param defaultValue Value returned if the property does not exist.
69 /// @return Value of the property, @em defaultValue otherwise.
70 double getDoubleProperty(const QString& name, double defaultValue = 0.0) const;
71
72 /// Set the value of a property.
73 /// @param name Name of the property.
74 /// @param value Value to set.
75 void setProperty(const QString& name, const QString& value);
76
77 /// Check if a property exists.
78 /// @param name Name of the property.
79 /// @return True if the property exists, false otherwise.
80 bool hasProperty(const QString& name) const;
81
82private:
83 // Returns the local QDomElement.
84 QDomElement qDomElement() const;
85
86 // Copy internally the node in the internal QDomElement.
87 void localCopy(const QDomElement& elementToCopy);
88
89 QString const getComponentName() const;
90 QString const getComponentType() const;
91
92private:
93 QDomElement component_;
94 XmlConfigFile * parentDocument_;
95};
96
97} // namespace pacpus
98
99#endif // DEF_PACPUS_XMLCOMPONENTCONFIG_H
Note: See TracBrowser for help on using the repository browser.