52 | | /*! |
53 | | \brief Read instance properties according the data stored in the Setting structure. |
54 | | It has to be called only through UI class, therefore it is protected |
55 | | |
56 | | At the begining of this method, it is obligatory to call |
57 | | the corresponding base::from_setting method. Sometimes, there can be |
58 | | an exception from this rule. If so, the programmer is encouraged |
59 | | to describe the reasons for this exception in the documentation in detail. |
60 | | |
61 | | Then, all the configuration components should be read through the UI mechanism. |
62 | | Those with UI::SettingPresence set to optional shoud have their defaults fulfilled |
63 | | within the body of this method. |
64 | | |
65 | | For instance, declaring a class \c trunk derived from our #root class, |
66 | | the implementation of the from_setting method should look like this |
67 | | |
68 | | \code |
69 | | |
70 | | public trunk : public root { |
71 | | |
72 | | anytype xxx, yyy; |
73 | | |
74 | | virtual void from_setting ( const Setting &set ) { |
75 | | root::from_setting( set ); |
76 | | |
77 | | UI::get ( xxx, set, "xxx", UI::compulsory ); |
78 | | |
79 | | if ( !UI::get ( yyy, set, "yyy", UI::optional ) ) { |
80 | | ... // here, it is necessary to set the default of attribute yyy |
81 | | } |
82 | | |
83 | | ... // another stuff related to trunk class |
84 | | } |
85 | | |
86 | | ... // other members of this class |
87 | | }; |
88 | | |
89 | | \endcode |
90 | | */ |
91 | | virtual void from_setting ( const Setting &set ) { |
92 | | } |
93 | | |
94 | | /*! |
95 | | \brief Save all the instance properties into the Setting structure. |
96 | | It has to be called only through UI class, therefore it is protected |
97 | | |
98 | | The only obligatory rule concerning the body of this method is to call |
99 | | the corresponding base::to_setting method first. Sometimes, there can |
100 | | be an exception from this rule. If so, the programmer is encouraged |
101 | | to describe the reasons for this exception in the documentation in detail. |
102 | | |
103 | | For instance, declaring |
104 | | a class \c trunk derived from our #root class, the implementation of |
105 | | the to_setting method should look like this |
106 | | |
107 | | \code |
108 | | public trunk : public root { |
109 | | |
110 | | anytype xxx; |
111 | | |
112 | | virtual void to_setting ( const Setting &set ) { |
113 | | root::to_setting( set ); |
114 | | |
115 | | UI::save ( xxx, set, "xxx" ); |
116 | | |
117 | | ... // another stuff related directly to trunk class |
118 | | |
119 | | } |
120 | | |
121 | | ... // other members of this class |
122 | | |
123 | | }; |
124 | | |
125 | | \endcode |
126 | | */ |
127 | | virtual void to_setting ( Setting &set ) const { |
128 | | } |
| 52 | /*! |
| 53 | \brief Read instance properties according the data stored in the Setting structure. |
| 54 | It has to be called only through UI class, therefore it is protected |
| 55 | |
| 56 | At the begining of this method, it is obligatory to call |
| 57 | the corresponding base::from_setting method. Sometimes, there can be |
| 58 | an exception from this rule. If so, the programmer is encouraged |
| 59 | to describe the reasons for this exception in the documentation in detail. |
| 60 | |
| 61 | Then, all the configuration components should be read through the UI mechanism. |
| 62 | Those with UI::SettingPresence set to optional shoud have their defaults fulfilled |
| 63 | within the body of this method. |
| 64 | |
| 65 | For instance, declaring a class \c trunk derived from our #root class, |
| 66 | the implementation of the from_setting method should look like this |
| 67 | |
| 68 | \code |
| 69 | |
| 70 | public trunk : public root { |
| 71 | |
| 72 | anytype xxx, yyy; |
| 73 | |
| 74 | virtual void from_setting ( const Setting &set ) { |
| 75 | root::from_setting( set ); |
| 76 | |
| 77 | UI::get ( xxx, set, "xxx", UI::compulsory ); |
| 78 | |
| 79 | if ( !UI::get ( yyy, set, "yyy", UI::optional ) ) { |
| 80 | ... // here, it is necessary to set the default of attribute yyy |
| 81 | } |
| 82 | |
| 83 | ... // another stuff related to trunk class |
| 84 | } |
| 85 | |
| 86 | ... // other members of this class |
| 87 | }; |
| 88 | |
| 89 | \endcode |
| 90 | */ |
| 91 | virtual void from_setting ( const Setting &set ) { |
| 92 | } |
| 93 | |
| 94 | /*! |
| 95 | \brief Save all the instance properties into the Setting structure. |
| 96 | It has to be called only through UI class, therefore it is protected |
| 97 | |
| 98 | The only obligatory rule concerning the body of this method is to call |
| 99 | the corresponding base::to_setting method first. Sometimes, there can |
| 100 | be an exception from this rule. If so, the programmer is encouraged |
| 101 | to describe the reasons for this exception in the documentation in detail. |
| 102 | |
| 103 | For instance, declaring |
| 104 | a class \c trunk derived from our #root class, the implementation of |
| 105 | the to_setting method should look like this |
| 106 | |
| 107 | \code |
| 108 | public trunk : public root { |
| 109 | |
| 110 | anytype xxx; |
| 111 | |
| 112 | virtual void to_setting ( const Setting &set ) { |
| 113 | root::to_setting( set ); |
| 114 | |
| 115 | UI::save ( xxx, set, "xxx" ); |
| 116 | |
| 117 | ... // another stuff related directly to trunk class |
| 118 | |
| 119 | } |
| 120 | |
| 121 | ... // other members of this class |
| 122 | |
| 123 | }; |
| 124 | |
| 125 | \endcode |
| 126 | */ |
| 127 | virtual void to_setting ( Setting &set ) const { |
| 128 | } |
131 | | |
132 | | //!default constructor |
133 | | root() {}; |
134 | | |
135 | | //! make sure this is a virtual object |
136 | | virtual ~root() { |
137 | | } |
138 | | |
139 | | //! Returns basic textual info about the current instance |
140 | | virtual string to_string() const { |
141 | | Config C; |
142 | | Setting &set=C.getRoot(); |
143 | | this->to_setting(set); |
144 | | ostringstream os; |
145 | | UI_DBG(set, "", os); |
146 | | return os.str(); |
147 | | } |
148 | | //! Register log levels of each inheritance layer to a logger, i.e. allocate space for data from this class |
149 | | virtual void log_register ( logger &L, const string &prefix ) { |
150 | | } |
151 | | |
152 | | //! Write current information into the given logger |
153 | | virtual void log_write() const { |
154 | | } |
155 | | |
156 | | /*! |
157 | | \brief This method checks that all internal structures has been set up correctly. |
158 | | |
159 | | It is called automatically after the call of the #from_setting method by the mechanism of the UI class. |
160 | | However, it can be called in any other situation to assure the correctness of an instance. |
161 | | |
162 | | The only obligatory rule concerning the body of this method is to call |
163 | | the corresponding base::validate method first. Sometimes, there can be |
164 | | an exception from this rule. If so, the programmer is encouraged |
165 | | to describe the reasons for this exception in the documentation in detail. |
166 | | |
167 | | Then, only those checks which are not implemented in the base method |
168 | | are implemented here. For instance, declaring a class \c trunk derived from our |
169 | | #root class, the implementation of the method validate should |
170 | | look like this |
171 | | |
172 | | \code |
173 | | public trunk : public root { |
174 | | |
175 | | virtual void validate ( ) { |
176 | | root::validate( ); |
177 | | |
178 | | ... // checks related directly to trunk class |
179 | | } |
180 | | |
181 | | ... // other members of this class |
182 | | |
183 | | }; |
184 | | |
185 | | \endcode |
186 | | |
187 | | */ |
188 | | virtual void validate() { |
189 | | } |
190 | | |
191 | | //! Virtual method providing deep copy of instances |
192 | | virtual root* _copy() const NOT_IMPLEMENTED(NULL); |
193 | | |
| 131 | |
| 132 | //!default constructor |
| 133 | root() {}; |
| 134 | |
| 135 | //! make sure this is a virtual object |
| 136 | virtual ~root() { |
| 137 | } |
| 138 | |
| 139 | //! Returns basic textual info about the current instance |
| 140 | virtual string to_string() const { |
| 141 | Config C; |
| 142 | Setting &set=C.getRoot(); |
| 143 | this->to_setting(set); |
| 144 | ostringstream os; |
| 145 | UI_DBG(set, "", os); |
| 146 | return os.str(); |
| 147 | } |
| 148 | //! Register log levels of each inheritance layer to a logger, i.e. allocate space for data from this class |
| 149 | virtual void log_register ( logger &L, const string &prefix ) { |
| 150 | } |
| 151 | |
| 152 | //! Write current information into the given logger |
| 153 | virtual void log_write() const { |
| 154 | } |
| 155 | |
| 156 | /*! |
| 157 | \brief This method checks that all internal structures has been set up correctly. |
| 158 | |
| 159 | It is called automatically after the call of the #from_setting method by the mechanism of the UI class. |
| 160 | However, it can be called in any other situation to assure the correctness of an instance. |
| 161 | |
| 162 | The only obligatory rule concerning the body of this method is to call |
| 163 | the corresponding base::validate method first. Sometimes, there can be |
| 164 | an exception from this rule. If so, the programmer is encouraged |
| 165 | to describe the reasons for this exception in the documentation in detail. |
| 166 | |
| 167 | Then, only those checks which are not implemented in the base method |
| 168 | are implemented here. For instance, declaring a class \c trunk derived from our |
| 169 | #root class, the implementation of the method validate should |
| 170 | look like this |
| 171 | |
| 172 | \code |
| 173 | public trunk : public root { |
| 174 | |
| 175 | virtual void validate ( ) { |
| 176 | root::validate( ); |
| 177 | |
| 178 | ... // checks related directly to trunk class |
| 179 | } |
| 180 | |
| 181 | ... // other members of this class |
| 182 | |
| 183 | }; |
| 184 | |
| 185 | \endcode |
| 186 | |
| 187 | */ |
| 188 | virtual void validate() { |
| 189 | } |
| 190 | |
| 191 | //! Virtual method providing deep copy of instances |
| 192 | virtual root* _copy() const NOT_IMPLEMENTED(NULL); |
| 193 | |