source: flair-src/trunk/lib/FlairCore/src/Widget.h@ 397

Last change on this file since 397 was 302, checked in by Sanahuja Guillaume, 6 years ago

modifs nouveau build system

File size: 4.0 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5/*!
6 * \file Widget.h
7 * \brief Abstract class for all Framework's widget classes
8 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
9 * \date 2012/05/02
10 * \version 4.0
11 */
12
13#ifndef WIDGET_H
14#define WIDGET_H
15
16#include <Object.h>
17
18class Widget_impl;
19class FrameworkManager_impl;
20typedef struct _xmlNode xmlNode;
21typedef xmlNode *xmlNodePtr;
22
23namespace flair {
24namespace gui {
25
26/*! \class Widget
27*
28* \brief Abstract class for all Framework's widget classes
29*
30* A widget is an object to display on the ground station. \n
31* Communication with ground station is done through xml files; properties of
32*theses files
33* are modified through appropriate method. \n
34* A xml file is used for default values of the Widget, if it has been specified
35*in the
36* constructor of the FrameworkManager.
37*/
38class Widget : public core::Object {
39 friend class core::FrameworkManager;
40 friend class ::Widget_impl;
41 friend class ::FrameworkManager_impl;
42
43public:
44 /*!
45 * \brief Constructor
46 *
47 * Construct a Widget, the xml file specified to the FrameworkManager's
48 * constructor is sued for default values. \n
49 * Two Widget with same parent must have different names. If a brother Widget
50 *already
51 * has the same name, the name of the new one will be automatically changed. \n
52 * Type must agree with predifined (hard coded) types
53 * in ground station code.
54 *
55 * \param parent parent
56 * \param name name
57 * \param type type
58 */
59 Widget(const Widget *parent, std::string name, std::string type);
60
61 /*!
62 * \brief Destructor
63 *
64 */
65 virtual ~Widget();
66
67 /*!
68 * \brief Set enabled
69 *
70 * Enable or disable the Widget on the ground station. \n
71 * A disabled widget is greyed out on the ground station
72 * and in unmodifiable.
73 *
74 * \param status
75 */
76 void setEnabled(bool status);
77
78 /*!
79 * \brief Is enabled?
80 *
81 * \return true if widget is enabled
82 */
83 bool isEnabled(void) const;
84
85protected:
86 /*!
87 * \brief Set a persistent xml property
88 *
89 * The property will be saved in the configuration xml and also used to
90 *configure the ground station.
91 *
92 * \param prop property to set and save
93 * \param value value to set and save
94 */
95 template <typename T> void SetPersistentXmlProp(std::string prop, T value);
96
97 /*!
98 * \brief Get a persistent xml property
99 *
100 * Get the property from the xml file. If no corresponding property is found in
101 *the xml, value remains unchanged. \n
102 * Thus value can be initialized with a default value before calling this
103 *method.
104 *
105 * \param prop property to get
106 * \param value value to store the result
107 * \return true if value was changed
108 */
109 template <typename T> bool GetPersistentXmlProp(std::string prop, T &value);
110
111 /*!
112 * \brief Set a volatile xml property
113 *
114 * This property should be used to configure the ground station (one time
115 *init). \n
116 * The property will be destroyed after calling SendXml() as it should no be
117 *used anymore.
118 *
119 * \param prop property to set
120 * \param value value to set
121 * \param node if sepcified, node to set; otherwise use the node of the Widget
122 */
123 template <typename T>
124 void SetVolatileXmlProp(std::string prop, T value, xmlNodePtr node = NULL);
125
126 /*!
127 * \brief Send xml
128 *
129 * Send Widget's xml to ground station. \n
130 * New changes will be taken into account by ground station. \n
131 * All volatile properties will be erased after calling ths method, as they
132 *should not be used anymore.
133 */
134 void SendXml(void);
135
136 /*!
137 * \brief Xml event
138 *
139 * This method must be reimplemented to handle a xml event. \n
140 * It is automatically called when something changed from
141 * ground station. \n
142 */
143 virtual void XmlEvent(void){};
144
145 /*!
146 * \brief Unset a persistent xml property
147 *
148 * Unset an existent property, so it won't be saved.
149 *
150 * \param prop property to set
151 */
152 void UnsetPersistentXmlProp(std::string prop);
153
154private:
155 class Widget_impl *pimpl_;
156};
157
158} // end namespace gui
159} // end namespace flair
160
161#endif // WIDGET_H
Note: See TracBrowser for help on using the repository browser.