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 | //#include <io_data.h> |
---|
18 | #include <libxml/xpath.h> |
---|
19 | |
---|
20 | class Widget_impl; |
---|
21 | class FrameworkManager_impl; |
---|
22 | |
---|
23 | namespace flair |
---|
24 | { |
---|
25 | namespace gui |
---|
26 | { |
---|
27 | |
---|
28 | /*! \class Widget |
---|
29 | * |
---|
30 | * \brief Abstract class for all Framework's widget classes |
---|
31 | * |
---|
32 | * A widget is an object to display on the ground station. \n |
---|
33 | * Communication with ground station is done through xml files; properties of theses files |
---|
34 | * are modified through appropriate method. \n |
---|
35 | * A xml file is used for default values of the Widget, if it has been specified in the |
---|
36 | * constructor of the FrameworkManager. |
---|
37 | */ |
---|
38 | class Widget: public core::Object |
---|
39 | { |
---|
40 | friend class core::FrameworkManager; |
---|
41 | friend class ::Widget_impl; |
---|
42 | friend class ::FrameworkManager_impl; |
---|
43 | |
---|
44 | public: |
---|
45 | /*! |
---|
46 | * \brief Constructor |
---|
47 | * |
---|
48 | * Construct a Widget, the xml file specified to the FrameworkManager's |
---|
49 | * constructor is sued for default values. \n |
---|
50 | * Two Widget with same parent must have different names. If a brother Widget 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 | |
---|
85 | protected: |
---|
86 | /*! |
---|
87 | * \brief Set a persistent xml property |
---|
88 | * |
---|
89 | * The property will be saved in the configuration xml and also used to configure the ground station. |
---|
90 | * |
---|
91 | * \param prop property to set and save |
---|
92 | * \param value value to set and save |
---|
93 | */ |
---|
94 | template <typename T> |
---|
95 | 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 the xml, value remains unchanged. \n |
---|
101 | * Thus value can be initialized with a default value before calling this method. |
---|
102 | * |
---|
103 | * \param prop property to get |
---|
104 | * \param value value to store the result |
---|
105 | * \return true if value was changed |
---|
106 | */ |
---|
107 | template <typename T> |
---|
108 | bool GetPersistentXmlProp(std::string prop,T &value); |
---|
109 | |
---|
110 | /*! |
---|
111 | * \brief Set a volatile xml property |
---|
112 | * |
---|
113 | * This property should be used to configure the ground station (one time init). \n |
---|
114 | * The property will be destroyed after calling SendXml() as it should no be used anymore. |
---|
115 | * |
---|
116 | * \param prop property to set |
---|
117 | * \param value value to set |
---|
118 | * \param node if sepcified, node to set; otherwise use the node of the Widget |
---|
119 | */ |
---|
120 | template <typename T> |
---|
121 | void SetVolatileXmlProp(std::string prop,T value,xmlNodePtr node=NULL); |
---|
122 | |
---|
123 | /*! |
---|
124 | * \brief Send xml |
---|
125 | * |
---|
126 | * Send Widget's xml to ground station. \n |
---|
127 | * New changes will be taken into account by ground station. \n |
---|
128 | * All volatile properties will be erased after calling ths method, as they should not be used anymore. |
---|
129 | */ |
---|
130 | void SendXml(void); |
---|
131 | |
---|
132 | /*! |
---|
133 | * \brief Xml event |
---|
134 | * |
---|
135 | * This method must be reimplemented to handle a xml event. \n |
---|
136 | * It is automatically called when something changed from |
---|
137 | * ground station. \n |
---|
138 | */ |
---|
139 | virtual void XmlEvent(void){}; |
---|
140 | |
---|
141 | private: |
---|
142 | class Widget_impl* pimpl_; |
---|
143 | }; |
---|
144 | |
---|
145 | } // end namespace gui |
---|
146 | } // end namespace flair |
---|
147 | |
---|
148 | #endif // WIDGET_H |
---|