90 | | <a name="l00045"></a><a class="code" href="classbdm_1_1UIException.html#c25dbbe6c642e5a70a810673ab9929d2">00045</a> <span class="keyword">const</span> <span class="keywordtype">string</span> <a class="code" href="classbdm_1_1UIException.html#c25dbbe6c642e5a70a810673ab9929d2" title="Path to the problematic setting.">path</a>; |
91 | | <a name="l00046"></a>00046 |
92 | | <a name="l00048"></a><a class="code" href="classbdm_1_1UIException.html#351bfe4a6e8d0288500e3412313f3301">00048</a> <a class="code" href="classbdm_1_1UIException.html#351bfe4a6e8d0288500e3412313f3301" title="Use this constructor when you can pass the problematical Setting as a parameter.">UIException</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &<a class="code" href="classbdm_1_1UIException.html#82b5104b04c1ed5047a7a344dc702f68" title="Error message.">message</a>, <span class="keyword">const</span> Setting &element ) |
93 | | <a name="l00049"></a>00049 : message ( <span class="stringliteral">"UI error: "</span> + message + <span class="stringliteral">"."</span> ), <a class="code" href="classbdm_1_1UIException.html#c25dbbe6c642e5a70a810673ab9929d2" title="Path to the problematic setting.">path</a> ( <span class="stringliteral">"Check path \""</span> + string ( element.getPath() ) + <span class="stringliteral">"\"."</span> ) { |
94 | | <a name="l00050"></a>00050 } |
95 | | <a name="l00051"></a>00051 |
96 | | <a name="l00053"></a><a class="code" href="classbdm_1_1UIException.html#691e5563c06a1d4d9e02e01a1a187dae">00053</a> <a class="code" href="classbdm_1_1UIException.html#351bfe4a6e8d0288500e3412313f3301" title="Use this constructor when you can pass the problematical Setting as a parameter.">UIException</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &<a class="code" href="classbdm_1_1UIException.html#82b5104b04c1ed5047a7a344dc702f68" title="Error message.">message</a>, <span class="keyword">const</span> <span class="keywordtype">string</span> &<a class="code" href="classbdm_1_1UIException.html#c25dbbe6c642e5a70a810673ab9929d2" title="Path to the problematic setting.">path</a> ) |
97 | | <a name="l00054"></a>00054 : message ( <span class="stringliteral">"UI error: "</span> + message + <span class="stringliteral">"."</span> ), path ( <span class="stringliteral">"Check path \""</span> + path + <span class="stringliteral">"\"."</span> ) { |
98 | | <a name="l00055"></a>00055 } |
99 | | <a name="l00056"></a>00056 |
100 | | <a name="l00058"></a><a class="code" href="classbdm_1_1UIException.html#1bf477e4ea19abb638fe5b883f09218e">00058</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classbdm_1_1UIException.html#1bf477e4ea19abb638fe5b883f09218e" title="Overriden method for reporting an error message.">what</a>() <span class="keyword">const</span> throw() { |
101 | | <a name="l00059"></a>00059 <span class="keywordflow">return</span> ( <a class="code" href="classbdm_1_1UIException.html#82b5104b04c1ed5047a7a344dc702f68" title="Error message.">message</a> + <span class="stringliteral">" "</span> + <a class="code" href="classbdm_1_1UIException.html#c25dbbe6c642e5a70a810673ab9929d2" title="Path to the problematic setting.">path</a> ).c_str(); |
102 | | <a name="l00060"></a>00060 } |
103 | | <a name="l00061"></a>00061 ~<a class="code" href="classbdm_1_1UIException.html">UIException</a>() throw() {}; |
104 | | <a name="l00062"></a>00062 }; |
105 | | <a name="l00063"></a>00063 |
106 | | <a name="l00064"></a>00064 |
107 | | <a name="l00089"></a><a class="code" href="classbdm_1_1UIFile.html">00089</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1UIFile.html" title="This class serves to load and/or save user-infos into/from configuration files stored...">UIFile</a> : <span class="keyword">public</span> Config { |
| 93 | <a name="l00044"></a>00044 <span class="keyword">public</span>: |
| 94 | <a name="l00049"></a><a class="code" href="classbdm_1_1UIException.html#a7b2b53f2265165deea6f7c0cce1aa770">00049</a> <a class="code" href="classbdm_1_1UIException.html#a7b2b53f2265165deea6f7c0cce1aa770" title="The constructor.">UIException</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &message ) : |
| 95 | <a name="l00050"></a>00050 message ( message ) { |
| 96 | <a name="l00051"></a>00051 } |
| 97 | <a name="l00052"></a>00052 |
| 98 | <a name="l00054"></a><a class="code" href="classbdm_1_1UIException.html#a1bf477e4ea19abb638fe5b883f09218e">00054</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classbdm_1_1UIException.html#a1bf477e4ea19abb638fe5b883f09218e" title="Overriden method for reporting the error message.">what</a>() <span class="keyword">const</span> throw() { |
| 99 | <a name="l00055"></a>00055 <span class="keywordflow">return</span> message.c_str(); |
| 100 | <a name="l00056"></a>00056 } |
| 101 | <a name="l00057"></a>00057 |
| 102 | <a name="l00058"></a>00058 ~<a class="code" href="classbdm_1_1UIException.html">UIException</a>() throw() {}; |
| 103 | <a name="l00059"></a>00059 |
| 104 | <a name="l00060"></a>00060 <span class="keyword">protected</span>: |
| 105 | <a name="l00065"></a>00065 <span class="keyword">static</span> <span class="keywordtype">string</span> <a class="code" href="classbdm_1_1UIException.html#a864c8a6b9000691ea3e0f2b48b6f9d6a">format_message</a>( <span class="keyword">const</span> <span class="keywordtype">string</span> &reason, <span class="keyword">const</span> <span class="keywordtype">string</span> &path ); |
| 106 | <a name="l00066"></a>00066 }; |
| 107 | <a name="l00067"></a>00067 |
| 108 | <a name="l00071"></a><a class="code" href="classbdm_1_1UISettingException.html">00071</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1UISettingException.html">UISettingException</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1UIException.html">UIException</a> { |
| 109 | <a name="l00072"></a>00072 <span class="keyword">public</span>: |
| 110 | <a name="l00074"></a><a class="code" href="classbdm_1_1UISettingException.html#a8cc4ce2a91b79b6bc88a3ca563799a4c">00074</a> <a class="code" href="classbdm_1_1UISettingException.html#a8cc4ce2a91b79b6bc88a3ca563799a4c" title="Use this constructor when you can pass the problematical Setting as a parameter.">UISettingException</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &message, <span class="keyword">const</span> Setting &element ): |
| 111 | <a name="l00075"></a>00075 <a class="code" href="classbdm_1_1UIException.html">UIException</a> ( <a class="code" href="classbdm_1_1UIException.html#a864c8a6b9000691ea3e0f2b48b6f9d6a">format_message</a> ( message, string ( element.getPath() ) ) ) { |
| 112 | <a name="l00076"></a>00076 } |
| 113 | <a name="l00077"></a>00077 |
| 114 | <a name="l00079"></a><a class="code" href="classbdm_1_1UISettingException.html#a3527101bc7d484b32c44561599dac706">00079</a> <a class="code" href="classbdm_1_1UISettingException.html#a8cc4ce2a91b79b6bc88a3ca563799a4c" title="Use this constructor when you can pass the problematical Setting as a parameter.">UISettingException</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &message, <span class="keyword">const</span> <span class="keywordtype">string</span> &path ): |
| 115 | <a name="l00080"></a>00080 <a class="code" href="classbdm_1_1UIException.html">UIException</a> ( <a class="code" href="classbdm_1_1UIException.html#a864c8a6b9000691ea3e0f2b48b6f9d6a">format_message</a> ( message, path ) ) { |
| 116 | <a name="l00081"></a>00081 } |
| 117 | <a name="l00082"></a>00082 |
| 118 | <a name="l00083"></a>00083 ~<a class="code" href="classbdm_1_1UISettingException.html">UISettingException</a>() throw() {}; |
| 119 | <a name="l00084"></a>00084 }; |
| 120 | <a name="l00085"></a>00085 |
| 121 | <a name="l00089"></a><a class="code" href="classbdm_1_1UIClassException.html">00089</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1UIClassException.html">UIClassException</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1UIException.html">UIException</a> { |
118 | | <a name="l00170"></a><a class="code" href="classbdm_1_1SettingResolver.html">00170</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1SettingResolver.html" title="This class serves to expand links used within configuration files.">SettingResolver</a> : <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> { |
119 | | <a name="l00171"></a>00171 <span class="keyword">private</span>: |
120 | | <a name="l00173"></a>00173 <a class="code" href="classbdm_1_1UIFile.html" title="This class serves to load and/or save user-infos into/from configuration files stored...">UIFile</a> *file; |
121 | | <a name="l00174"></a>00174 |
122 | | <a name="l00180"></a>00180 <span class="keyword">const</span> Setting &initialize_reference ( <a class="code" href="classbdm_1_1UIFile.html" title="This class serves to load and/or save user-infos into/from configuration files stored...">UIFile</a>* &file, <span class="keyword">const</span> Setting &potential_link ); |
123 | | <a name="l00181"></a>00181 |
124 | | <a name="l00182"></a>00182 <span class="keyword">public</span>: |
125 | | <a name="l00184"></a><a class="code" href="classbdm_1_1SettingResolver.html#adfcd0a81d025c52c8335b6aea07b498">00184</a> <span class="keyword">const</span> Setting &<a class="code" href="classbdm_1_1SettingResolver.html#adfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a>; |
126 | | <a name="l00185"></a>00185 |
127 | | <a name="l00187"></a>00187 <a class="code" href="classbdm_1_1SettingResolver.html#e2299746b95bf8af54a867aaf52fc8da" title="If potential_link contains a link to some other setting, it is resolved here. Anyway...">SettingResolver</a> ( <span class="keyword">const</span> Setting &potential_link ); |
128 | | <a name="l00188"></a>00188 |
129 | | <a name="l00190"></a>00190 <a class="code" href="classbdm_1_1SettingResolver.html#c8b29999710e2db98c1a3979e25e6bbc" title="An opened UIFile file is closed here if necessary.">~SettingResolver</a>(); |
130 | | <a name="l00191"></a>00191 }; |
131 | | <a name="l00192"></a>00192 |
132 | | <a name="l00203"></a><a class="code" href="classbdm_1_1UI.html">00203</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class which collects all the auxiliary functions useful to prepare...">UI</a> { |
133 | | <a name="l00204"></a>00204 <span class="keyword">private</span>: |
134 | | <a name="l00210"></a>00210 <span class="keyword">class </span>MappedUI { |
135 | | <a name="l00211"></a>00211 <span class="keyword">private</span>: |
136 | | <a name="l00213"></a>00213 <span class="keyword">typedef</span> map< const string, const UI* const > StringToUIMap; |
137 | | <a name="l00214"></a>00214 |
138 | | <a name="l00216"></a>00216 <span class="keyword">typedef</span> map< const type_info * const, const string > TypeInfoToStringMap; |
139 | | <a name="l00217"></a>00217 |
140 | | <a name="l00219"></a>00219 <span class="keyword">static</span> StringToUIMap& mapped_strings(); |
| 134 | <a name="l00128"></a><a class="code" href="classbdm_1_1UIFile.html">00128</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1UIFile.html" title="This class serves to load and/or save user-infos into/from configuration files stored...">UIFile</a> : <span class="keyword">public</span> Config { |
| 135 | <a name="l00129"></a>00129 <span class="keyword">public</span>: |
| 136 | <a name="l00131"></a>00131 <a class="code" href="classbdm_1_1UIFile.html#a77274c827f87f16bd6671df8a0cc1e33" title="Create empty file instance prepared to store Settings.">UIFile</a>(); |
| 137 | <a name="l00132"></a>00132 |
| 138 | <a name="l00134"></a>00134 <a class="code" href="classbdm_1_1UIFile.html#a77274c827f87f16bd6671df8a0cc1e33" title="Create empty file instance prepared to store Settings.">UIFile</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &file_name ); |
| 139 | <a name="l00135"></a>00135 |
| 140 | <a name="l00137"></a>00137 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UIFile.html#a1f8af28a0d8ef1a4956e198df0beb5ba" title="Save all the stored Settings into the configuration file file_name.">save</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &file_name ); |
| 141 | <a name="l00138"></a>00138 |
| 142 | <a name="l00140"></a>00140 <a class="code" href="classbdm_1_1UIFile.html#a5bce10d88c71f6147d58baa8400ff61f" title="This operator allows the ability of substituting Setting parameter by UIFile instance...">operator Setting&</a>(); |
| 143 | <a name="l00141"></a>00141 }; |
| 144 | <a name="l00142"></a>00142 |
| 145 | <a name="l00209"></a><a class="code" href="classbdm_1_1SettingResolver.html">00209</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1SettingResolver.html" title="This class serves to expand links used within configuration files.">SettingResolver</a> : <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> { |
| 146 | <a name="l00210"></a>00210 <span class="keyword">private</span>: |
| 147 | <a name="l00212"></a>00212 <a class="code" href="classbdm_1_1UIFile.html" title="This class serves to load and/or save user-infos into/from configuration files stored...">UIFile</a> *file; |
| 148 | <a name="l00213"></a>00213 |
| 149 | <a name="l00219"></a>00219 <span class="keyword">const</span> Setting &initialize_reference ( <a class="code" href="classbdm_1_1UIFile.html" title="This class serves to load and/or save user-infos into/from configuration files stored...">UIFile</a>* &file, <span class="keyword">const</span> Setting &potential_link ); |
142 | | <a name="l00222"></a>00222 <span class="keyword">static</span> TypeInfoToStringMap& mapped_type_infos(); |
143 | | <a name="l00223"></a>00223 |
144 | | <a name="l00225"></a>00225 <span class="keyword">static</span> <span class="keywordtype">void</span> unregistered_class_error ( <span class="keyword">const</span> <span class="keywordtype">string</span> &unregistered_class_name ); |
145 | | <a name="l00226"></a>00226 |
146 | | <a name="l00227"></a>00227 <span class="keyword">public</span>: |
147 | | <a name="l00229"></a>00229 <span class="keyword">static</span> <span class="keywordtype">void</span> add_class ( <span class="keyword">const</span> <span class="keywordtype">string</span> &class_name, <span class="keyword">const</span> type_info * <span class="keyword">const</span> class_type_info, <span class="keyword">const</span> <a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class which collects all the auxiliary functions useful to prepare...">UI</a>* <span class="keyword">const</span> ui ); |
148 | | <a name="l00230"></a>00230 |
149 | | <a name="l00232"></a>00232 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class which collects all the auxiliary functions useful to prepare...">UI</a>& retrieve_ui ( <span class="keyword">const</span> <span class="keywordtype">string</span> &class_name ); |
150 | | <a name="l00233"></a>00233 |
151 | | <a name="l00235"></a>00235 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">string</span>& retrieve_class_name ( <span class="keyword">const</span> type_info* <span class="keyword">const</span> class_type_info ); |
152 | | <a name="l00236"></a>00236 }; |
153 | | <a name="l00237"></a>00237 |
154 | | <a name="l00239"></a>00239 <span class="keyword">static</span> <span class="keywordtype">void</span> assert_type ( <span class="keyword">const</span> Setting &element, Setting::Type type ); |
155 | | <a name="l00240"></a>00240 |
156 | | <a name="l00242"></a>00242 <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a>* new_instance() <span class="keyword">const</span> = 0; |
157 | | <a name="l00243"></a>00243 |
158 | | <a name="l00245"></a>00245 <span class="keyword">static</span> <span class="keyword">const</span> Setting& to_child_setting ( <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">int</span> index ); |
159 | | <a name="l00246"></a>00246 |
160 | | <a name="l00248"></a>00248 <span class="keyword">static</span> <span class="keyword">const</span> Setting& to_child_setting ( <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name ); |
161 | | <a name="l00249"></a>00249 |
162 | | <a name="l00251"></a>00251 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( mat& matrix, <span class="keyword">const</span> Setting &element ); |
163 | | <a name="l00253"></a>00253 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( ivec &vector, <span class="keyword">const</span> Setting &element ); |
164 | | <a name="l00255"></a>00255 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( <span class="keywordtype">string</span> &<a class="code" href="classbdm_1_1str.html" title="Structure of RV, i.e. RVs expanded into a flat list of IDs, used for debugging.">str</a>, <span class="keyword">const</span> Setting &element ); |
165 | | <a name="l00257"></a>00257 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( vec &vector, <span class="keyword">const</span> Setting &element ); |
166 | | <a name="l00259"></a>00259 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( <span class="keywordtype">int</span> &integer, <span class="keyword">const</span> Setting &element ); |
167 | | <a name="l00261"></a>00261 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( <span class="keywordtype">double</span> &real, <span class="keyword">const</span> Setting &element ); |
168 | | <a name="l00263"></a>00263 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( T* &instance, <span class="keyword">const</span> Setting &element ) { |
169 | | <a name="l00264"></a>00264 <span class="keyword">const</span> <a class="code" href="classbdm_1_1SettingResolver.html" title="This class serves to expand links used within configuration files.">SettingResolver</a> link ( element ); |
170 | | <a name="l00265"></a>00265 assert_type ( link.<a class="code" href="classbdm_1_1SettingResolver.html#adfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a>, Setting::TypeGroup ); |
171 | | <a name="l00266"></a>00266 |
172 | | <a name="l00267"></a>00267 <span class="comment">// we get a value stored in the "class" attribute</span> |
173 | | <a name="l00268"></a>00268 <span class="keywordtype">string</span> class_name; |
174 | | <a name="l00269"></a>00269 <span class="keywordflow">if</span> ( !link.<a class="code" href="classbdm_1_1SettingResolver.html#adfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a>.lookupValue ( <span class="stringliteral">"class"</span>, class_name ) ) |
175 | | <a name="l00270"></a>00270 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UIException.html">UIException</a> ( <span class="stringliteral">"the obligatory \"class\" identifier is missing"</span>, link.<a class="code" href="classbdm_1_1SettingResolver.html#adfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a> ); |
176 | | <a name="l00271"></a>00271 |
177 | | <a name="l00272"></a>00272 <span class="comment">// then we find a user-info related to this type</span> |
178 | | <a name="l00273"></a>00273 <span class="keyword">const</span> <a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class which collects all the auxiliary functions useful to prepare...">UI</a>& related_UI = MappedUI::retrieve_ui ( class_name ); |
179 | | <a name="l00274"></a>00274 |
180 | | <a name="l00275"></a>00275 <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a>* typeless_instance = related_UI.new_instance(); |
| 151 | <a name="l00221"></a>00221 <span class="keyword">public</span>: |
| 152 | <a name="l00223"></a><a class="code" href="classbdm_1_1SettingResolver.html#aadfcd0a81d025c52c8335b6aea07b498">00223</a> <span class="keyword">const</span> Setting &<a class="code" href="classbdm_1_1SettingResolver.html#aadfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a>; |
| 153 | <a name="l00224"></a>00224 |
| 154 | <a name="l00226"></a>00226 <a class="code" href="classbdm_1_1SettingResolver.html#ae2299746b95bf8af54a867aaf52fc8da" title="If potential_link contains a link to some other setting, it is resolved here. Anyway...">SettingResolver</a> ( <span class="keyword">const</span> Setting &potential_link ); |
| 155 | <a name="l00227"></a>00227 |
| 156 | <a name="l00229"></a>00229 <a class="code" href="classbdm_1_1SettingResolver.html#ac8b29999710e2db98c1a3979e25e6bbc" title="An opened UIFile file is closed here if necessary.">~SettingResolver</a>(); |
| 157 | <a name="l00230"></a>00230 }; |
| 158 | <a name="l00231"></a>00231 |
| 159 | <a name="l00242"></a><a class="code" href="classbdm_1_1UI.html">00242</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class which collects all the auxiliary functions useful to prepare...">UI</a> { |
| 160 | <a name="l00243"></a>00243 <span class="keyword">private</span>: |
| 161 | <a name="l00249"></a>00249 <span class="keyword">class </span>MappedUI { |
| 162 | <a name="l00250"></a>00250 <span class="keyword">private</span>: |
| 163 | <a name="l00252"></a>00252 <span class="keyword">typedef</span> map< const string, const UI* const > StringToUIMap; |
| 164 | <a name="l00253"></a>00253 |
| 165 | <a name="l00255"></a>00255 <span class="keyword">typedef</span> map< const type_info * const, const string > TypeInfoToStringMap; |
| 166 | <a name="l00256"></a>00256 |
| 167 | <a name="l00258"></a>00258 <span class="keyword">static</span> StringToUIMap& mapped_strings(); |
| 168 | <a name="l00259"></a>00259 |
| 169 | <a name="l00261"></a>00261 <span class="keyword">static</span> TypeInfoToStringMap& mapped_type_infos(); |
| 170 | <a name="l00262"></a>00262 |
| 171 | <a name="l00264"></a>00264 <span class="keyword">static</span> <span class="keywordtype">void</span> unregistered_class_error ( <span class="keyword">const</span> <span class="keywordtype">string</span> &unregistered_class_name ); |
| 172 | <a name="l00265"></a>00265 |
| 173 | <a name="l00266"></a>00266 <span class="keyword">public</span>: |
| 174 | <a name="l00268"></a>00268 <span class="keyword">static</span> <span class="keywordtype">void</span> add_class ( <span class="keyword">const</span> <span class="keywordtype">string</span> &class_name, <span class="keyword">const</span> type_info * <span class="keyword">const</span> class_type_info, <span class="keyword">const</span> <a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class which collects all the auxiliary functions useful to prepare...">UI</a>* <span class="keyword">const</span> ui ); |
| 175 | <a name="l00269"></a>00269 |
| 176 | <a name="l00271"></a>00271 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class which collects all the auxiliary functions useful to prepare...">UI</a>& retrieve_ui ( <span class="keyword">const</span> <span class="keywordtype">string</span> &class_name ); |
| 177 | <a name="l00272"></a>00272 |
| 178 | <a name="l00274"></a>00274 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">string</span>& retrieve_class_name ( <span class="keyword">const</span> type_info* <span class="keyword">const</span> class_type_info ); |
| 179 | <a name="l00275"></a>00275 }; |
182 | | <a name="l00277"></a>00277 instance = <span class="keyword">dynamic_cast<</span>T*<span class="keyword">></span> ( typeless_instance ); |
183 | | <a name="l00278"></a>00278 <span class="keywordflow">if</span> ( !instance ) |
184 | | <a name="l00279"></a>00279 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UIException.html">UIException</a> ( <span class="stringliteral">"class "</span> + class_name + <span class="stringliteral">" is not a descendant of the desired output class. Try to call the UI::build<T> function with a different type parameter."</span>, link.<a class="code" href="classbdm_1_1SettingResolver.html#adfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a> ); |
185 | | <a name="l00280"></a>00280 |
186 | | <a name="l00281"></a>00281 <span class="keywordflow">try</span> { |
187 | | <a name="l00282"></a>00282 instance->from_setting ( link.<a class="code" href="classbdm_1_1SettingResolver.html#adfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a> ); |
188 | | <a name="l00283"></a>00283 } <span class="keywordflow">catch</span> ( SettingException sttng_xcptn ) { |
189 | | <a name="l00284"></a>00284 <span class="keywordtype">string</span> msg = <span class="stringliteral">"the method "</span> + class_name + <span class="stringliteral">".from_setting(Setting&) has thrown a SettingException. Try to correct this method. Check path \""</span> + sttng_xcptn.getPath() + <span class="stringliteral">"\"."</span>; |
190 | | <a name="l00285"></a>00285 <span class="keywordflow">throw</span> exception ( msg.c_str() ); |
191 | | <a name="l00286"></a>00286 } <span class="keywordflow">catch</span> ( <a class="code" href="classbdm_1_1UIException.html">UIException</a> uixcptn ) { |
192 | | <a name="l00287"></a>00287 <span class="keywordtype">string</span> msg = <span class="stringliteral">"the method "</span> + class_name + <span class="stringliteral">".from_setting(Setting&) has thrown an UIException \""</span> + uixcptn.<a class="code" href="classbdm_1_1UIException.html#82b5104b04c1ed5047a7a344dc702f68" title="Error message.">message</a> + <span class="stringliteral">"\" Try to correct this method. Check path \""</span> + uixcptn.<a class="code" href="classbdm_1_1UIException.html#c25dbbe6c642e5a70a810673ab9929d2" title="Path to the problematic setting.">path</a> + <span class="stringliteral">"\"."</span>; |
193 | | <a name="l00288"></a>00288 <span class="keywordflow">throw</span> exception ( msg.c_str() ); |
194 | | <a name="l00289"></a>00289 } <span class="keywordflow">catch</span> ( exception xcptn ) { |
195 | | <a name="l00290"></a>00290 <span class="keywordtype">string</span> msg = <span class="stringliteral">"the method "</span> + class_name + <span class="stringliteral">".from_setting(Setting&) has thrown a general exception \""</span> + xcptn.what() + <span class="stringliteral">"\" Try to correct this method. Check path \""</span> + element.getPath() + <span class="stringliteral">"\"."</span>; |
196 | | <a name="l00291"></a>00291 <span class="keywordflow">throw</span> exception ( msg.c_str() ); |
197 | | <a name="l00292"></a>00292 } |
198 | | <a name="l00293"></a>00293 } |
199 | | <a name="l00294"></a>00294 |
200 | | <a name="l00296"></a>00296 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( Array<T> &array_to_load, <span class="keyword">const</span> Setting &element ) { |
201 | | <a name="l00297"></a>00297 <span class="keyword">const</span> <a class="code" href="classbdm_1_1SettingResolver.html" title="This class serves to expand links used within configuration files.">SettingResolver</a> link ( element ); |
202 | | <a name="l00298"></a>00298 |
203 | | <a name="l00299"></a>00299 assert_type ( link.<a class="code" href="classbdm_1_1SettingResolver.html#adfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a>, Setting::TypeList ); |
204 | | <a name="l00300"></a>00300 |
205 | | <a name="l00301"></a>00301 <span class="keywordtype">int</span> len = link.<a class="code" href="classbdm_1_1SettingResolver.html#adfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a>.getLength(); |
206 | | <a name="l00302"></a>00302 array_to_load.set_length ( len ); |
207 | | <a name="l00303"></a>00303 <span class="keywordflow">if</span> ( len == 0 ) <span class="keywordflow">return</span>; |
208 | | <a name="l00304"></a>00304 |
209 | | <a name="l00305"></a>00305 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < len; i++ ) |
210 | | <a name="l00306"></a>00306 from_setting ( array_to_load ( i ), link.<a class="code" href="classbdm_1_1SettingResolver.html#adfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a>[i] ); |
211 | | <a name="l00307"></a>00307 } |
| 181 | <a name="l00278"></a>00278 <span class="keyword">static</span> <span class="keywordtype">void</span> assert_type ( <span class="keyword">const</span> Setting &element, Setting::Type type ); |
| 182 | <a name="l00279"></a>00279 |
| 183 | <a name="l00288"></a>00288 <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a>* new_instance() <span class="keyword">const</span> = 0; |
| 184 | <a name="l00289"></a>00289 |
| 185 | <a name="l00291"></a>00291 <span class="keyword">static</span> <span class="keyword">const</span> Setting& to_child_setting ( <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">int</span> index ); |
| 186 | <a name="l00292"></a>00292 |
| 187 | <a name="l00294"></a>00294 <span class="keyword">static</span> <span class="keyword">const</span> Setting& to_child_setting ( <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name ); |
| 188 | <a name="l00295"></a>00295 |
| 189 | <a name="l00297"></a>00297 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( mat& matrix, <span class="keyword">const</span> Setting &element ); |
| 190 | <a name="l00299"></a>00299 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( ivec &vector, <span class="keyword">const</span> Setting &element ); |
| 191 | <a name="l00301"></a>00301 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( <span class="keywordtype">string</span> &<a class="code" href="classbdm_1_1str.html" title="Structure of RV, i.e. RVs expanded into a flat list of IDs, used for debugging.">str</a>, <span class="keyword">const</span> Setting &element ); |
| 192 | <a name="l00303"></a>00303 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( vec &vector, <span class="keyword">const</span> Setting &element ); |
| 193 | <a name="l00305"></a>00305 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( <span class="keywordtype">int</span> &integer, <span class="keyword">const</span> Setting &element ); |
| 194 | <a name="l00307"></a>00307 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( <span class="keywordtype">double</span> &real, <span class="keyword">const</span> Setting &element ); |
213 | | <a name="l00313"></a>00313 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( T &array_to_load, <span class="keyword">const</span> Setting &element ) { |
214 | | <a name="l00314"></a>00314 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UIException.html">UIException</a>( <span class="stringliteral">"from_setting is not implemented for this type"</span>, element ); |
215 | | <a name="l00315"></a>00315 } |
216 | | <a name="l00316"></a>00316 |
217 | | <a name="l00317"></a>00317 |
218 | | <a name="l00318"></a>00318 <span class="keyword">protected</span>: |
219 | | <a name="l00320"></a><a class="code" href="classbdm_1_1UI.html#d60234c0673f345424329894b9b0cef8">00320</a> <a class="code" href="classbdm_1_1UI.html#d60234c0673f345424329894b9b0cef8" title="Default constructor for internal use only, see.">UI</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span>& class_name, <span class="keyword">const</span> type_info * <span class="keyword">const</span> class_type_info ) { |
220 | | <a name="l00321"></a>00321 MappedUI::add_class ( class_name, class_type_info, <span class="keyword">this</span> ); |
221 | | <a name="l00322"></a>00322 } |
222 | | <a name="l00323"></a>00323 |
223 | | <a name="l00324"></a>00324 <span class="keyword">public</span>: |
224 | | <a name="l00325"></a>00325 |
225 | | <a name="l00327"></a><a class="code" href="classbdm_1_1UI.html#88d02c1ffe93033af0f146e8008ab6e6">00327</a> <span class="keyword">enum</span> <a class="code" href="classbdm_1_1UI.html#88d02c1ffe93033af0f146e8008ab6e6" title="Enumerical type used to determine whether the data for concrete Settingis is compulsory...">SettingPresence</a> { optional, compulsory } ; |
226 | | <a name="l00328"></a>00328 |
227 | | <a name="l00332"></a>00332 |
228 | | <a name="l00336"></a><a class="code" href="classbdm_1_1UI.html#970297d6c758692135877dfa7a5eacb0">00336</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> T* <a class="code" href="classbdm_1_1UI.html#970297d6c758692135877dfa7a5eacb0">build</a> ( <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name, <a class="code" href="classbdm_1_1UI.html#88d02c1ffe93033af0f146e8008ab6e6" title="Enumerical type used to determine whether the data for concrete Settingis is compulsory...">SettingPresence</a> settingPresence = optional ) { |
229 | | <a name="l00337"></a>00337 <span class="keywordflow">if</span> ( !element.exists ( name ) ) |
230 | | <a name="l00338"></a>00338 { |
231 | | <a name="l00339"></a>00339 <span class="keywordflow">if</span>( settingPresence == optional ) |
232 | | <a name="l00340"></a>00340 <span class="keywordflow">return</span> NULL; |
233 | | <a name="l00341"></a>00341 <span class="keywordflow">else</span> |
234 | | <a name="l00342"></a>00342 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UIException.html">UIException</a> ( <span class="stringliteral">"the compulsory Setting named \""</span> + name + <span class="stringliteral">"\" is missing"</span>, element ); |
235 | | <a name="l00343"></a>00343 } |
236 | | <a name="l00344"></a>00344 |
237 | | <a name="l00345"></a>00345 T* instance; |
238 | | <a name="l00346"></a>00346 from_setting<T> ( instance, to_child_setting ( element, name ) ); |
239 | | <a name="l00347"></a>00347 <span class="keywordflow">return</span> instance; |
240 | | <a name="l00348"></a>00348 } |
241 | | <a name="l00349"></a>00349 |
242 | | <a name="l00353"></a><a class="code" href="classbdm_1_1UI.html#b8b2512d4762463cbf23314d45f1c5b1">00353</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> T* <a class="code" href="classbdm_1_1UI.html#b8b2512d4762463cbf23314d45f1c5b1">build</a> ( <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">int</span> index, <a class="code" href="classbdm_1_1UI.html#88d02c1ffe93033af0f146e8008ab6e6" title="Enumerical type used to determine whether the data for concrete Settingis is compulsory...">SettingPresence</a> settingPresence = optional ) { |
243 | | <a name="l00354"></a>00354 <span class="keywordflow">if</span> ( element.getLength() <= index ) |
244 | | <a name="l00355"></a>00355 { |
245 | | <a name="l00356"></a>00356 <span class="keywordflow">if</span>( settingPresence == optional ) |
246 | | <a name="l00357"></a>00357 <span class="keywordflow">return</span> NULL; |
247 | | <a name="l00358"></a>00358 <span class="keywordflow">else</span> |
248 | | <a name="l00359"></a>00359 { |
249 | | <a name="l00360"></a>00360 stringstream stream; |
250 | | <a name="l00361"></a>00361 stream << index; |
251 | | <a name="l00362"></a>00362 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UIException.html">UIException</a> ( <span class="stringliteral">"the compulsory Setting with the index "</span> + stream.str()+ <span class="stringliteral">" is missing"</span>, element ); |
252 | | <a name="l00363"></a>00363 } |
253 | | <a name="l00364"></a>00364 } |
254 | | <a name="l00365"></a>00365 |
255 | | <a name="l00366"></a>00366 T* instance; |
256 | | <a name="l00367"></a>00367 from_setting<T> ( instance, to_child_setting ( element, index ) ); |
257 | | <a name="l00368"></a>00368 <span class="keywordflow">return</span> instance; |
| 196 | <a name="l00310"></a>00310 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( T* &instance, <span class="keyword">const</span> Setting &element ) { |
| 197 | <a name="l00311"></a>00311 <span class="keyword">const</span> <a class="code" href="classbdm_1_1SettingResolver.html" title="This class serves to expand links used within configuration files.">SettingResolver</a> link ( element ); |
| 198 | <a name="l00312"></a>00312 assert_type ( link.<a class="code" href="classbdm_1_1SettingResolver.html#aadfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a>, Setting::TypeGroup ); |
| 199 | <a name="l00313"></a>00313 |
| 200 | <a name="l00314"></a>00314 <span class="comment">// we get a value stored in the "class" attribute</span> |
| 201 | <a name="l00315"></a>00315 <span class="keywordtype">string</span> class_name; |
| 202 | <a name="l00316"></a>00316 <span class="keywordflow">if</span> ( !link.<a class="code" href="classbdm_1_1SettingResolver.html#aadfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a>.lookupValue ( <span class="stringliteral">"class"</span>, class_name ) ) |
| 203 | <a name="l00317"></a>00317 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UIClassException.html">UIClassException</a> ( <span class="stringliteral">"UIException: the obligatory \"class\" identifier is missing."</span>, link.<a class="code" href="classbdm_1_1SettingResolver.html#aadfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a> ); |
| 204 | <a name="l00318"></a>00318 |
| 205 | <a name="l00319"></a>00319 <span class="comment">// then we find a user-info related to this type</span> |
| 206 | <a name="l00320"></a>00320 <span class="keyword">const</span> <a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class which collects all the auxiliary functions useful to prepare...">UI</a>& related_UI = MappedUI::retrieve_ui ( class_name ); |
| 207 | <a name="l00321"></a>00321 |
| 208 | <a name="l00322"></a>00322 <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> *typeless_instance = related_UI.new_instance(); |
| 209 | <a name="l00323"></a>00323 <a class="code" href="bdmerror_8h.html#a89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</a> ( typeless_instance, <span class="stringliteral">"UI::new_instance failed"</span> ); |
| 210 | <a name="l00324"></a>00324 |
| 211 | <a name="l00325"></a>00325 instance = <span class="keyword">dynamic_cast<</span>T*<span class="keyword">></span> ( typeless_instance ); |
| 212 | <a name="l00326"></a>00326 <span class="keywordflow">if</span> ( !instance ) { |
| 213 | <a name="l00327"></a>00327 <span class="keyword">delete</span> typeless_instance; |
| 214 | <a name="l00328"></a>00328 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UIClassException.html">UIClassException</a> ( <span class="stringliteral">"UIException: class "</span> + class_name + <span class="stringliteral">" is not a descendant of the desired output class. Try to call the UI::build<T> function with a different type parameter."</span>, link.<a class="code" href="classbdm_1_1SettingResolver.html#aadfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a> ); |
| 215 | <a name="l00329"></a>00329 } |
| 216 | <a name="l00330"></a>00330 |
| 217 | <a name="l00331"></a>00331 <span class="keywordflow">try</span> { |
| 218 | <a name="l00332"></a>00332 instance->from_setting ( link.<a class="code" href="classbdm_1_1SettingResolver.html#aadfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a> ); |
| 219 | <a name="l00333"></a>00333 } <span class="keywordflow">catch</span> ( SettingException &sttng_xcptn ) { |
| 220 | <a name="l00334"></a>00334 <span class="keyword">delete</span> instance; |
| 221 | <a name="l00335"></a>00335 instance = 0; |
| 222 | <a name="l00336"></a>00336 <span class="keywordtype">string</span> msg = <span class="stringliteral">"UIException: method "</span>; |
| 223 | <a name="l00337"></a>00337 msg += class_name; |
| 224 | <a name="l00338"></a>00338 msg += <span class="stringliteral">".from_setting(Setting&) has thrown a SettingException."</span>; |
| 225 | <a name="l00339"></a>00339 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UISettingException.html">UISettingException</a>(msg, sttng_xcptn.getPath()); |
| 226 | <a name="l00340"></a>00340 } <span class="keywordflow">catch</span> (...) { |
| 227 | <a name="l00341"></a>00341 <span class="keyword">delete</span> instance; |
| 228 | <a name="l00342"></a>00342 instance = 0; |
| 229 | <a name="l00343"></a>00343 <span class="keywordflow">throw</span>; |
| 230 | <a name="l00344"></a>00344 } |
| 231 | <a name="l00345"></a>00345 } |
| 232 | <a name="l00346"></a>00346 |
| 233 | <a name="l00349"></a>00349 <span class="keyword">template</span><<span class="keyword">class</span> T> |
| 234 | <a name="l00350"></a>00350 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( <a class="code" href="classbdm_1_1shared__ptr.html" title="A naive implementation of roughly a subset of the std::tr1::shared_ptr spec.">shared_ptr<T></a> &instance, <span class="keyword">const</span> Setting &element ) { |
| 235 | <a name="l00351"></a>00351 T *tmp_inst = 0; |
| 236 | <a name="l00352"></a>00352 from_setting ( tmp_inst, element ); |
| 237 | <a name="l00353"></a>00353 <a class="code" href="bdmerror_8h.html#a89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</a> ( tmp_inst, <span class="stringliteral">"UI::from_setting failed"</span> ); |
| 238 | <a name="l00354"></a>00354 instance = tmp_inst; |
| 239 | <a name="l00355"></a>00355 } |
| 240 | <a name="l00356"></a>00356 |
| 241 | <a name="l00358"></a>00358 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( Array<T> &array_to_load, <span class="keyword">const</span> Setting &element ) { |
| 242 | <a name="l00359"></a>00359 <span class="keyword">const</span> <a class="code" href="classbdm_1_1SettingResolver.html" title="This class serves to expand links used within configuration files.">SettingResolver</a> link ( element ); |
| 243 | <a name="l00360"></a>00360 |
| 244 | <a name="l00361"></a>00361 assert_type ( link.<a class="code" href="classbdm_1_1SettingResolver.html#aadfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a>, Setting::TypeList ); |
| 245 | <a name="l00362"></a>00362 |
| 246 | <a name="l00363"></a>00363 <span class="keywordtype">int</span> len = link.<a class="code" href="classbdm_1_1SettingResolver.html#aadfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a>.getLength(); |
| 247 | <a name="l00364"></a>00364 array_to_load.set_length ( len ); |
| 248 | <a name="l00365"></a>00365 <span class="keywordflow">if</span> ( len == 0 ) <span class="keywordflow">return</span>; |
| 249 | <a name="l00366"></a>00366 |
| 250 | <a name="l00367"></a>00367 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < len; i++ ) |
| 251 | <a name="l00368"></a>00368 from_setting ( array_to_load ( i ), link.<a class="code" href="classbdm_1_1SettingResolver.html#aadfcd0a81d025c52c8335b6aea07b498" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a>[i] ); |
260 | | <a name="l00372"></a><a class="code" href="classbdm_1_1UI.html#6e2da6a142fecf5f21e0bb86a7211cb4">00372</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> T* <a class="code" href="classbdm_1_1UI.html#6e2da6a142fecf5f21e0bb86a7211cb4" title="The new instance of type T* is constructed and initialized with values stored in...">build</a> ( <span class="keyword">const</span> Setting &element ) { |
261 | | <a name="l00373"></a>00373 T* instance; |
262 | | <a name="l00374"></a>00374 from_setting<T> ( instance, element ); |
263 | | <a name="l00375"></a>00375 <span class="keywordflow">return</span> instance; |
264 | | <a name="l00376"></a>00376 |
265 | | <a name="l00377"></a>00377 } |
266 | | <a name="l00378"></a>00378 |
267 | | <a name="l00380"></a>00380 |
268 | | <a name="l00384"></a>00384 |
269 | | <a name="l00387"></a><a class="code" href="classbdm_1_1UI.html#cd1667e6fec99ec64dabcb3ca2ff922d">00387</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">bool</span> <span class="keyword">get</span> ( T &instance, <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name, <a class="code" href="classbdm_1_1UI.html#88d02c1ffe93033af0f146e8008ab6e6" title="Enumerical type used to determine whether the data for concrete Settingis is compulsory...">SettingPresence</a> settingPresence = optional ) { |
270 | | <a name="l00388"></a>00388 <span class="keywordflow">if</span> ( !element.exists ( name ) ) |
271 | | <a name="l00389"></a>00389 { |
272 | | <a name="l00390"></a>00390 <span class="keywordflow">if</span>( settingPresence == optional ) |
273 | | <a name="l00391"></a>00391 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
274 | | <a name="l00392"></a>00392 <span class="keywordflow">else</span> |
275 | | <a name="l00393"></a>00393 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UIException.html">UIException</a> ( <span class="stringliteral">"the compulsory Setting named \""</span> + name + <span class="stringliteral">"\" is missing"</span>, element ); |
276 | | <a name="l00394"></a>00394 } |
277 | | <a name="l00395"></a>00395 |
278 | | <a name="l00396"></a>00396 from_setting ( instance, to_child_setting ( element, name ) ); |
279 | | <a name="l00397"></a>00397 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
280 | | <a name="l00398"></a>00398 } |
281 | | <a name="l00399"></a>00399 |
282 | | <a name="l00402"></a><a class="code" href="classbdm_1_1UI.html#6fb95ccb13515a3f23080a397dacaa0e">00402</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">bool</span> <span class="keyword">get</span> ( T &instance, <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">int</span> index, <a class="code" href="classbdm_1_1UI.html#88d02c1ffe93033af0f146e8008ab6e6" title="Enumerical type used to determine whether the data for concrete Settingis is compulsory...">SettingPresence</a> settingPresence = optional ) { |
283 | | <a name="l00403"></a>00403 <span class="keywordflow">if</span> ( element.getLength() <= index ) |
284 | | <a name="l00404"></a>00404 { |
285 | | <a name="l00405"></a>00405 <span class="keywordflow">if</span>( settingPresence == optional ) |
286 | | <a name="l00406"></a>00406 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
287 | | <a name="l00407"></a>00407 <span class="keywordflow">else</span> |
288 | | <a name="l00408"></a>00408 { |
289 | | <a name="l00409"></a>00409 stringstream stream; |
290 | | <a name="l00410"></a>00410 stream << index; |
291 | | <a name="l00411"></a>00411 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UIException.html">UIException</a> ( <span class="stringliteral">"the compulsory Setting with the index "</span> + stream.str()+ <span class="stringliteral">" is missing"</span>, element ); |
292 | | <a name="l00412"></a>00412 } |
293 | | <a name="l00413"></a>00413 } |
| 254 | <a name="l00375"></a>00375 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting ( T &variable_to_load, <span class="keyword">const</span> Setting &element ) { |
| 255 | <a name="l00376"></a>00376 std::string msg = <span class="stringliteral">"UIException: from_setting is not implemented for type "</span>; |
| 256 | <a name="l00377"></a>00377 msg += <span class="keyword">typeid</span>(T).name(); |
| 257 | <a name="l00378"></a>00378 msg += <span class="charliteral">'.'</span>; |
| 258 | <a name="l00379"></a>00379 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UISettingException.html">UISettingException</a> ( msg, element ); |
| 259 | <a name="l00380"></a>00380 } |
| 260 | <a name="l00381"></a>00381 |
| 261 | <a name="l00382"></a>00382 |
| 262 | <a name="l00383"></a>00383 <span class="keyword">protected</span>: |
| 263 | <a name="l00385"></a><a class="code" href="classbdm_1_1UI.html#ad60234c0673f345424329894b9b0cef8">00385</a> <a class="code" href="classbdm_1_1UI.html#ad60234c0673f345424329894b9b0cef8" title="Constructor for internal use only, see.">UI</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span>& class_name, <span class="keyword">const</span> type_info * <span class="keyword">const</span> class_type_info ) { |
| 264 | <a name="l00386"></a>00386 MappedUI::add_class ( class_name, class_type_info, <span class="keyword">this</span> ); |
| 265 | <a name="l00387"></a>00387 } |
| 266 | <a name="l00388"></a>00388 |
| 267 | <a name="l00389"></a>00389 <span class="keyword">public</span>: |
| 268 | <a name="l00390"></a>00390 |
| 269 | <a name="l00392"></a><a class="code" href="classbdm_1_1UI.html#a88d02c1ffe93033af0f146e8008ab6e6">00392</a> <span class="keyword">enum</span> <a class="code" href="classbdm_1_1UI.html#a88d02c1ffe93033af0f146e8008ab6e6" title="Enum type used to determine whether the data for concrete Settingis is compulsory...">SettingPresence</a> { optional, compulsory } ; |
| 270 | <a name="l00393"></a>00393 |
| 271 | <a name="l00397"></a>00397 |
| 272 | <a name="l00401"></a>00401 <span class="keyword">template</span><<span class="keyword">class</span> T> |
| 273 | <a name="l00402"></a><a class="code" href="classbdm_1_1UI.html#a1f3d45184f803e1256cfc896b43ed2f8">00402</a> <span class="keyword">static</span> <a class="code" href="classbdm_1_1shared__ptr.html" title="A naive implementation of roughly a subset of the std::tr1::shared_ptr spec.">shared_ptr<T></a> <a class="code" href="classbdm_1_1UI.html#a1f3d45184f803e1256cfc896b43ed2f8">build</a> ( <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name, <a class="code" href="classbdm_1_1UI.html#a88d02c1ffe93033af0f146e8008ab6e6" title="Enum type used to determine whether the data for concrete Settingis is compulsory...">SettingPresence</a> settingPresence = optional ) { |
| 274 | <a name="l00403"></a>00403 <span class="keywordflow">if</span> ( !element.exists ( name ) ) { |
| 275 | <a name="l00404"></a>00404 <span class="keywordflow">if</span> ( settingPresence == optional ) |
| 276 | <a name="l00405"></a>00405 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1shared__ptr.html" title="A naive implementation of roughly a subset of the std::tr1::shared_ptr spec.">shared_ptr<T></a>(); |
| 277 | <a name="l00406"></a>00406 <span class="keywordflow">else</span> |
| 278 | <a name="l00407"></a>00407 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UISettingException.html">UISettingException</a> ( <span class="stringliteral">"UIException: the compulsory Setting named \""</span> + name + <span class="stringliteral">"\" is missing."</span>, element ); |
| 279 | <a name="l00408"></a>00408 } |
| 280 | <a name="l00409"></a>00409 |
| 281 | <a name="l00410"></a>00410 <a class="code" href="classbdm_1_1shared__ptr.html" title="A naive implementation of roughly a subset of the std::tr1::shared_ptr spec.">shared_ptr<T></a> instance; |
| 282 | <a name="l00411"></a>00411 from_setting<T> ( instance, to_child_setting ( element, name ) ); |
| 283 | <a name="l00412"></a>00412 <span class="keywordflow">return</span> instance; |
| 284 | <a name="l00413"></a>00413 } |
305 | | <a name="l00432"></a><a class="code" href="classbdm_1_1UI.html#81ce18ed0bb9993a634db2b99612ad66">00432</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">bool</span> <span class="keyword">get</span> ( Array<T> &array_to_load, <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name, <a class="code" href="classbdm_1_1UI.html#88d02c1ffe93033af0f146e8008ab6e6" title="Enumerical type used to determine whether the data for concrete Settingis is compulsory...">SettingPresence</a> settingPresence = optional ) { |
306 | | <a name="l00433"></a>00433 <span class="keywordflow">if</span> ( !element.exists ( name ) ) |
307 | | <a name="l00434"></a>00434 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
308 | | <a name="l00435"></a>00435 |
309 | | <a name="l00436"></a>00436 from_setting ( array_to_load, to_child_setting ( element, name ) ); |
310 | | <a name="l00437"></a>00437 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
311 | | <a name="l00438"></a>00438 } |
312 | | <a name="l00439"></a>00439 |
313 | | <a name="l00442"></a><a class="code" href="classbdm_1_1UI.html#29e450ed5560f81ef2f845e7b1021b71">00442</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">bool</span> <span class="keyword">get</span> ( Array<T> &array_to_load, <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">int</span> index, <a class="code" href="classbdm_1_1UI.html#88d02c1ffe93033af0f146e8008ab6e6" title="Enumerical type used to determine whether the data for concrete Settingis is compulsory...">SettingPresence</a> settingPresence = optional ) { |
314 | | <a name="l00443"></a>00443 <span class="keywordflow">if</span> ( element.getLength() <= index ) |
315 | | <a name="l00444"></a>00444 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
316 | | <a name="l00445"></a>00445 |
317 | | <a name="l00446"></a>00446 from_setting ( array_to_load, to_child_setting ( element, index ) ); |
318 | | <a name="l00447"></a>00447 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
319 | | <a name="l00448"></a>00448 } |
320 | | <a name="l00449"></a>00449 |
321 | | <a name="l00451"></a><a class="code" href="classbdm_1_1UI.html#c9fad8376d2f0857e719511f92f93998">00451</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">bool</span> <span class="keyword">get</span> ( Array<T> &array_to_load, <span class="keyword">const</span> Setting &element ) { |
322 | | <a name="l00452"></a>00452 from_setting ( array_to_load, element ); |
323 | | <a name="l00453"></a>00453 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
324 | | <a name="l00454"></a>00454 } |
325 | | <a name="l00456"></a>00456 |
326 | | <a name="l00461"></a>00461 |
327 | | <a name="l00463"></a><a class="code" href="classbdm_1_1UI.html#c83987949e6a9e79d6e093797ab7d917">00463</a> <span class="keyword">template</span>< <span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#c83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> T * <span class="keyword">const</span> instance, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ) { |
328 | | <a name="l00464"></a>00464 Setting &<span class="keyword">set</span> = ( name == <span class="stringliteral">""</span> ) ? element.add ( Setting::TypeGroup ) |
329 | | <a name="l00465"></a>00465 : element.add ( name, Setting::TypeGroup ); |
330 | | <a name="l00466"></a>00466 |
331 | | <a name="l00467"></a>00467 <span class="keyword">const</span> <span class="keywordtype">string</span> &class_name = MappedUI::retrieve_class_name ( &<span class="keyword">typeid</span> ( *instance ) ); |
| 298 | <a name="l00430"></a>00430 <a class="code" href="classbdm_1_1shared__ptr.html" title="A naive implementation of roughly a subset of the std::tr1::shared_ptr spec.">shared_ptr<T></a> instance; |
| 299 | <a name="l00431"></a>00431 from_setting<T> ( instance, to_child_setting ( element, index ) ); |
| 300 | <a name="l00432"></a>00432 <span class="keywordflow">return</span> instance; |
| 301 | <a name="l00433"></a>00433 } |
| 302 | <a name="l00434"></a>00434 |
| 303 | <a name="l00436"></a>00436 |
| 304 | <a name="l00440"></a>00440 |
| 305 | <a name="l00443"></a><a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">00443</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">bool</span> <span class="keyword">get</span> ( T &instance, <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name, <a class="code" href="classbdm_1_1UI.html#a88d02c1ffe93033af0f146e8008ab6e6" title="Enum type used to determine whether the data for concrete Settingis is compulsory...">SettingPresence</a> settingPresence = optional ) { |
| 306 | <a name="l00444"></a>00444 <span class="keywordflow">if</span> ( !element.exists ( name ) ) { |
| 307 | <a name="l00445"></a>00445 <span class="keywordflow">if</span> ( settingPresence == optional ) |
| 308 | <a name="l00446"></a>00446 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
| 309 | <a name="l00447"></a>00447 <span class="keywordflow">else</span> |
| 310 | <a name="l00448"></a>00448 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UISettingException.html">UISettingException</a> ( <span class="stringliteral">"UIException: the compulsory Setting named \""</span> + name + <span class="stringliteral">"\" is missing."</span>, element ); |
| 311 | <a name="l00449"></a>00449 } |
| 312 | <a name="l00450"></a>00450 |
| 313 | <a name="l00451"></a>00451 from_setting ( instance, to_child_setting ( element, name ) ); |
| 314 | <a name="l00452"></a>00452 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
| 315 | <a name="l00453"></a>00453 } |
| 316 | <a name="l00454"></a>00454 |
| 317 | <a name="l00457"></a><a class="code" href="classbdm_1_1UI.html#a6fb95ccb13515a3f23080a397dacaa0e">00457</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">bool</span> <span class="keyword">get</span> ( T &instance, <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">int</span> index, <a class="code" href="classbdm_1_1UI.html#a88d02c1ffe93033af0f146e8008ab6e6" title="Enum type used to determine whether the data for concrete Settingis is compulsory...">SettingPresence</a> settingPresence = optional ) { |
| 318 | <a name="l00458"></a>00458 <span class="keywordflow">if</span> ( element.getLength() <= index ) { |
| 319 | <a name="l00459"></a>00459 <span class="keywordflow">if</span> ( settingPresence == optional ) |
| 320 | <a name="l00460"></a>00460 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
| 321 | <a name="l00461"></a>00461 <span class="keywordflow">else</span> { |
| 322 | <a name="l00462"></a>00462 stringstream stream; |
| 323 | <a name="l00463"></a>00463 stream << <span class="stringliteral">"UIException: the compulsory Setting with the index "</span> << index << <span class="stringliteral">" is missing."</span>; |
| 324 | <a name="l00464"></a>00464 stream << index; |
| 325 | <a name="l00465"></a>00465 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UISettingException.html">UISettingException</a> (stream.str(), element ); |
| 326 | <a name="l00466"></a>00466 } |
| 327 | <a name="l00467"></a>00467 } |
337 | | <a name="l00473"></a>00473 <span class="keywordflow">try</span> { |
338 | | <a name="l00474"></a>00474 instance->to_setting ( <span class="keyword">set</span> ); |
339 | | <a name="l00475"></a>00475 } <span class="keywordflow">catch</span> ( SettingException sttng_xcptn ) { |
340 | | <a name="l00476"></a>00476 <span class="keywordtype">string</span> msg = <span class="stringliteral">"the method "</span> + class_name + <span class="stringliteral">".to_setting(Setting&) has thrown a SettingException. Try to correct this method. Check path \""</span> + sttng_xcptn.getPath() + <span class="stringliteral">"\"."</span>; |
341 | | <a name="l00477"></a>00477 <span class="keywordflow">throw</span> exception ( msg.c_str() ); |
342 | | <a name="l00478"></a>00478 } <span class="keywordflow">catch</span> ( <a class="code" href="classbdm_1_1UIException.html">UIException</a> uixcptn ) { |
343 | | <a name="l00479"></a>00479 <span class="keywordtype">string</span> msg = <span class="stringliteral">"the method "</span> + class_name + <span class="stringliteral">".to_setting(Setting&) has thrown an UIException \""</span> + uixcptn.<a class="code" href="classbdm_1_1UIException.html#82b5104b04c1ed5047a7a344dc702f68" title="Error message.">message</a> + <span class="stringliteral">"\" Try to correct this method. Check path \""</span> + uixcptn.<a class="code" href="classbdm_1_1UIException.html#c25dbbe6c642e5a70a810673ab9929d2" title="Path to the problematic setting.">path</a> + <span class="stringliteral">"\"."</span>; |
344 | | <a name="l00480"></a>00480 <span class="keywordflow">throw</span> exception ( msg.c_str() ); |
345 | | <a name="l00481"></a>00481 } <span class="keywordflow">catch</span> ( exception xcptn ) { |
346 | | <a name="l00482"></a>00482 <span class="keywordtype">string</span> msg = <span class="stringliteral">"the method "</span> + class_name + <span class="stringliteral">".to_setting(Setting&) has thrown a general exception \""</span> + xcptn.what() + <span class="stringliteral">"\" Try to correct this method. Check path \""</span> + element.getPath() + <span class="stringliteral">"\"."</span>; |
347 | | <a name="l00483"></a>00483 <span class="keywordflow">throw</span> exception ( msg.c_str() ); |
348 | | <a name="l00484"></a>00484 } |
349 | | <a name="l00485"></a>00485 } |
350 | | <a name="l00486"></a>00486 |
351 | | <a name="l00488"></a><a class="code" href="classbdm_1_1UI.html#4514f93573a9d9126c506d176fbd3163">00488</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#4514f93573a9d9126c506d176fbd3163" title="An Array&lt;T&gt; instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> Array<T> &array_to_save, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ) { |
352 | | <a name="l00489"></a>00489 assert_type ( element, Setting::TypeGroup ); |
353 | | <a name="l00490"></a>00490 Setting &list = ( name == <span class="stringliteral">""</span> ) ? element.add ( Setting::TypeList ) |
354 | | <a name="l00491"></a>00491 : element.add ( name, Setting::TypeList ); |
355 | | <a name="l00492"></a>00492 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < array_to_save.length(); i++ ) |
356 | | <a name="l00493"></a>00493 <a class="code" href="classbdm_1_1UI.html#c83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( array_to_save ( i ), list ); |
357 | | <a name="l00494"></a>00494 } |
358 | | <a name="l00495"></a>00495 |
359 | | <a name="l00497"></a>00497 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#c83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> mat &matrix, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ); |
360 | | <a name="l00498"></a>00498 |
361 | | <a name="l00500"></a>00500 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#c83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> ivec &vec, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ); |
362 | | <a name="l00501"></a>00501 |
363 | | <a name="l00503"></a>00503 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#c83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> vec &vector, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ); |
364 | | <a name="l00504"></a>00504 |
365 | | <a name="l00506"></a>00506 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#c83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &str, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ); |
366 | | <a name="l00507"></a>00507 |
367 | | <a name="l00509"></a>00509 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#c83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> <span class="keywordtype">int</span> &integer, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ); |
| 333 | <a name="l00474"></a><a class="code" href="classbdm_1_1UI.html#a7d2ea138c7285565507fa61fbd9b038f">00474</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">bool</span> <span class="keyword">get</span> ( T &instance, <span class="keyword">const</span> Setting &element ) { |
| 334 | <a name="l00475"></a>00475 from_setting ( instance, element ); |
| 335 | <a name="l00476"></a>00476 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
| 336 | <a name="l00477"></a>00477 } |
| 337 | <a name="l00479"></a>00479 |
| 338 | <a name="l00483"></a>00483 |
| 339 | <a name="l00486"></a><a class="code" href="classbdm_1_1UI.html#a81ce18ed0bb9993a634db2b99612ad66">00486</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">bool</span> <span class="keyword">get</span> ( Array<T> &array_to_load, <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name, <a class="code" href="classbdm_1_1UI.html#a88d02c1ffe93033af0f146e8008ab6e6" title="Enum type used to determine whether the data for concrete Settingis is compulsory...">SettingPresence</a> settingPresence = optional ) { |
| 340 | <a name="l00487"></a>00487 <span class="keywordflow">if</span> ( !element.exists ( name ) ) |
| 341 | <a name="l00488"></a>00488 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
| 342 | <a name="l00489"></a>00489 |
| 343 | <a name="l00490"></a>00490 from_setting ( array_to_load, to_child_setting ( element, name ) ); |
| 344 | <a name="l00491"></a>00491 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
| 345 | <a name="l00492"></a>00492 } |
| 346 | <a name="l00493"></a>00493 |
| 347 | <a name="l00496"></a><a class="code" href="classbdm_1_1UI.html#a29e450ed5560f81ef2f845e7b1021b71">00496</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">bool</span> <span class="keyword">get</span> ( Array<T> &array_to_load, <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">int</span> index, <a class="code" href="classbdm_1_1UI.html#a88d02c1ffe93033af0f146e8008ab6e6" title="Enum type used to determine whether the data for concrete Settingis is compulsory...">SettingPresence</a> settingPresence = optional ) { |
| 348 | <a name="l00497"></a>00497 <span class="keywordflow">if</span> ( element.getLength() <= index ) |
| 349 | <a name="l00498"></a>00498 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
| 350 | <a name="l00499"></a>00499 |
| 351 | <a name="l00500"></a>00500 from_setting ( array_to_load, to_child_setting ( element, index ) ); |
| 352 | <a name="l00501"></a>00501 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
| 353 | <a name="l00502"></a>00502 } |
| 354 | <a name="l00503"></a>00503 |
| 355 | <a name="l00505"></a><a class="code" href="classbdm_1_1UI.html#ac9fad8376d2f0857e719511f92f93998">00505</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">bool</span> <span class="keyword">get</span> ( Array<T> &array_to_load, <span class="keyword">const</span> Setting &element ) { |
| 356 | <a name="l00506"></a>00506 from_setting ( array_to_load, element ); |
| 357 | <a name="l00507"></a>00507 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
| 358 | <a name="l00508"></a>00508 } |
369 | | <a name="l00512"></a>00512 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#c83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> <span class="keywordtype">double</span> &real, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ); |
370 | | <a name="l00514"></a>00514 |
371 | | <a name="l00515"></a>00515 }; |
372 | | <a name="l00516"></a>00516 |
373 | | <a name="l00517"></a>00517 |
374 | | <a name="l00520"></a><a class="code" href="classbdm_1_1ParticularUI.html">00520</a> <span class="keyword">template</span><<span class="keyword">typename</span> T> <span class="keyword">class </span><a class="code" href="classbdm_1_1ParticularUI.html">ParticularUI</a> : <span class="keyword">private</span> <a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class which collects all the auxiliary functions useful to prepare...">UI</a> { |
375 | | <a name="l00521"></a>00521 <span class="keyword">private</span>: |
376 | | <a name="l00523"></a><a class="code" href="classbdm_1_1ParticularUI.html#18a208b7549160ae6aeb884dc2bcd90f">00523</a> <a class="code" href="classbdm_1_1ParticularUI.html">ParticularUI<T></a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &class_name ) : <a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class which collects all the auxiliary functions useful to prepare...">UI</a> ( class_name, &<span class="keyword">typeid</span> ( T ) ) {}; |
377 | | <a name="l00524"></a>00524 |
378 | | <a name="l00525"></a>00525 <span class="keyword">public</span>: |
379 | | <a name="l00527"></a>00527 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classbdm_1_1ParticularUI.html">ParticularUI<T></a>& <a class="code" href="classbdm_1_1ParticularUI.html#18a208b7549160ae6aeb884dc2bcd90f" title="The only instance of this class (each type T has its own instance) which is used...">factory</a>; |
380 | | <a name="l00528"></a>00528 |
381 | | <a name="l00530"></a><a class="code" href="classbdm_1_1ParticularUI.html#a14fea8c7372a3d0a736e4ed0b617702">00530</a> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a>* <a class="code" href="classbdm_1_1ParticularUI.html#a14fea8c7372a3d0a736e4ed0b617702" title="A method returning a brand new instance of class T, this method is the reason why...">new_instance</a>()<span class="keyword"> const </span>{ |
382 | | <a name="l00531"></a>00531 <span class="keywordflow">return</span> <span class="keyword">new</span> T(); |
383 | | <a name="l00532"></a>00532 } |
384 | | <a name="l00533"></a>00533 }; |
385 | | <a name="l00534"></a>00534 |
386 | | <a name="l00535"></a>00535 } |
| 360 | <a name="l00515"></a>00515 |
| 361 | <a name="l00517"></a><a class="code" href="classbdm_1_1UI.html#ac83987949e6a9e79d6e093797ab7d917">00517</a> <span class="keyword">template</span>< <span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#ac83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> T * <span class="keyword">const</span> instance, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ) { |
| 362 | <a name="l00518"></a>00518 Setting &<span class="keyword">set</span> = ( name == <span class="stringliteral">""</span> ) ? element.add ( Setting::TypeGroup ) |
| 363 | <a name="l00519"></a>00519 : element.add ( name, Setting::TypeGroup ); |
| 364 | <a name="l00520"></a>00520 |
| 365 | <a name="l00521"></a>00521 <span class="keyword">const</span> <span class="keywordtype">string</span> &class_name = MappedUI::retrieve_class_name ( &<span class="keyword">typeid</span> ( *instance ) ); |
| 366 | <a name="l00522"></a>00522 |
| 367 | <a name="l00523"></a>00523 <span class="comment">// add attribute "class"</span> |
| 368 | <a name="l00524"></a>00524 Setting &type = <span class="keyword">set</span>.add ( <span class="stringliteral">"class"</span>, Setting::TypeString ); |
| 369 | <a name="l00525"></a>00525 type = class_name; |
| 370 | <a name="l00526"></a>00526 |
| 371 | <a name="l00527"></a>00527 <span class="keywordflow">try</span> { |
| 372 | <a name="l00528"></a>00528 instance->to_setting ( <span class="keyword">set</span> ); |
| 373 | <a name="l00529"></a>00529 } <span class="keywordflow">catch</span> ( SettingException &sttng_xcptn ) { |
| 374 | <a name="l00530"></a>00530 <span class="keywordtype">string</span> msg = <span class="stringliteral">"UIException: method "</span>; |
| 375 | <a name="l00531"></a>00531 msg += class_name; |
| 376 | <a name="l00532"></a>00532 msg += <span class="stringliteral">".to_setting(Setting&) has thrown a SettingException."</span>; |
| 377 | <a name="l00533"></a>00533 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UISettingException.html">UISettingException</a>(msg, sttng_xcptn.getPath()); |
| 378 | <a name="l00534"></a>00534 } |
| 379 | <a name="l00535"></a>00535 } |
388 | | <a name="l00546"></a>00546 <span class="preprocessor">#ifndef BDMLIB</span> |
389 | | <a name="l00547"></a><a class="code" href="user__info_8h.html#4f9de2f17e844047726487b99def99c6">00547</a> <span class="preprocessor"></span><span class="preprocessor">#define UIREGISTER(class_name) template<> const ParticularUI<class_name>& ParticularUI<class_name>::factory = ParticularUI<class_name>(#class_name)</span> |
390 | | <a name="l00548"></a>00548 <span class="preprocessor"></span><span class="preprocessor">#else</span> |
391 | | <a name="l00549"></a>00549 <span class="preprocessor"></span><span class="preprocessor">#define UIREGISTER(class_name)</span> |
392 | | <a name="l00550"></a>00550 <span class="preprocessor"></span><span class="preprocessor">#endif</span> |
393 | | <a name="l00551"></a>00551 <span class="preprocessor"></span> |
394 | | <a name="l00552"></a>00552 <span class="preprocessor">#endif // #ifndef USER_INFO_H</span> |
| 381 | <a name="l00537"></a>00537 <span class="keyword">template</span>< <span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#ac83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1shared__ptr.html" title="A naive implementation of roughly a subset of the std::tr1::shared_ptr spec.">shared_ptr<T></a> &instance, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ) { |
| 382 | <a name="l00538"></a>00538 save<T> ( instance.<a class="code" href="classbdm_1_1shared__ptr.html#a37ebcfb6750dd7b5630f1d2354c07a96">get</a>(), element, name ); |
| 383 | <a name="l00539"></a>00539 } |
| 384 | <a name="l00540"></a>00540 |
| 385 | <a name="l00542"></a><a class="code" href="classbdm_1_1UI.html#a4514f93573a9d9126c506d176fbd3163">00542</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#a4514f93573a9d9126c506d176fbd3163" title="An Array&lt;T&gt; instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> Array<T> &array_to_save, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ) { |
| 386 | <a name="l00543"></a>00543 assert_type ( element, Setting::TypeGroup ); |
| 387 | <a name="l00544"></a>00544 Setting &list = ( name == <span class="stringliteral">""</span> ) ? element.add ( Setting::TypeList ) |
| 388 | <a name="l00545"></a>00545 : element.add ( name, Setting::TypeList ); |
| 389 | <a name="l00546"></a>00546 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < array_to_save.length(); i++ ) |
| 390 | <a name="l00547"></a>00547 <a class="code" href="classbdm_1_1UI.html#ac83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( array_to_save ( i ), list ); |
| 391 | <a name="l00548"></a>00548 } |
| 392 | <a name="l00549"></a>00549 |
| 393 | <a name="l00551"></a>00551 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#ac83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> mat &matrix, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ); |
| 394 | <a name="l00552"></a>00552 |
| 395 | <a name="l00554"></a>00554 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#ac83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> ivec &vec, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ); |
| 396 | <a name="l00555"></a>00555 |
| 397 | <a name="l00557"></a>00557 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#ac83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> vec &vector, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ); |
| 398 | <a name="l00558"></a>00558 |
| 399 | <a name="l00560"></a>00560 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#ac83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &str, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ); |
| 400 | <a name="l00561"></a>00561 |
| 401 | <a name="l00563"></a>00563 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#ac83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> <span class="keywordtype">int</span> &integer, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ); |
| 402 | <a name="l00564"></a>00564 |
| 403 | <a name="l00566"></a>00566 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1UI.html#ac83987949e6a9e79d6e093797ab7d917" title="A root descendant instance is stored in the new child Setting appended to the passed...">save</a> ( <span class="keyword">const</span> <span class="keywordtype">double</span> &real, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ); |
| 404 | <a name="l00568"></a>00568 |
| 405 | <a name="l00569"></a>00569 }; |
| 406 | <a name="l00570"></a>00570 |
| 407 | <a name="l00571"></a>00571 |
| 408 | <a name="l00574"></a><a class="code" href="classbdm_1_1ParticularUI.html">00574</a> <span class="keyword">template</span><<span class="keyword">typename</span> T> <span class="keyword">class </span><a class="code" href="classbdm_1_1ParticularUI.html">ParticularUI</a> : <span class="keyword">private</span> <a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class which collects all the auxiliary functions useful to prepare...">UI</a> { |
| 409 | <a name="l00575"></a>00575 <span class="keyword">public</span>: |
| 410 | <a name="l00577"></a>00577 <a class="code" href="classbdm_1_1ParticularUI.html">ParticularUI<T></a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &class_name ) : <a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class which collects all the auxiliary functions useful to prepare...">UI</a> ( class_name, &<span class="keyword">typeid</span> ( T ) ) {}; |
| 411 | <a name="l00578"></a>00578 |
| 412 | <a name="l00580"></a><a class="code" href="classbdm_1_1ParticularUI.html#aa14fea8c7372a3d0a736e4ed0b617702">00580</a> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a>* <a class="code" href="classbdm_1_1ParticularUI.html#aa14fea8c7372a3d0a736e4ed0b617702" title="A method returning a brand new instance of class T, this method is the reason why...">new_instance</a>()<span class="keyword"> const </span>{ |
| 413 | <a name="l00581"></a>00581 <span class="keywordflow">return</span> <span class="keyword">new</span> T(); |
| 414 | <a name="l00582"></a>00582 } |
| 415 | <a name="l00583"></a>00583 }; |
| 416 | <a name="l00584"></a>00584 |
| 417 | <a name="l00585"></a>00585 } |
| 418 | <a name="l00586"></a>00586 |
| 419 | <a name="l00596"></a>00596 <span class="preprocessor">#ifndef BDMLIB</span> |
| 420 | <a name="l00597"></a><a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6">00597</a> <span class="preprocessor"></span><span class="preprocessor">#define UIREGISTER(class_name) static bdm::ParticularUI<class_name> UI##class_name(#class_name)</span> |
| 421 | <a name="l00598"></a>00598 <span class="preprocessor"></span><span class="preprocessor">#else</span> |
| 422 | <a name="l00599"></a>00599 <span class="preprocessor"></span><span class="preprocessor">#define UIREGISTER(class_name)</span> |
| 423 | <a name="l00600"></a>00600 <span class="preprocessor"></span><span class="preprocessor">#endif</span> |
| 424 | <a name="l00601"></a>00601 <span class="preprocessor"></span> |
| 425 | <a name="l00603"></a><a class="code" href="user__info_8h.html#a852592d44ce65a0a870c76b42155aaca">00603</a> <span class="preprocessor">#define QUOTEME(x) #x</span> |
| 426 | <a name="l00604"></a>00604 <span class="preprocessor"></span> |
| 427 | <a name="l00613"></a>00613 <span class="preprocessor">#ifndef BDMLIB</span> |
| 428 | <a name="l00614"></a><a class="code" href="user__info_8h.html#ab06f1e7c44a8306e321f62a0099210b9">00614</a> <span class="preprocessor"></span><span class="preprocessor">#define UIREGISTER2(class_name, temp_name) static bdm::ParticularUI<class_name<temp_name> > UI##class_name##_##temp_name( QUOTEME(class_name<temp_name>) )</span> |
| 429 | <a name="l00615"></a>00615 <span class="preprocessor"></span><span class="preprocessor">#else</span> |
| 430 | <a name="l00616"></a>00616 <span class="preprocessor"></span><span class="preprocessor">#define UIREGISTER2(class_name,temp_name) </span> |
| 431 | <a name="l00617"></a>00617 <span class="preprocessor"></span><span class="preprocessor">#endif</span> |
| 432 | <a name="l00618"></a>00618 <span class="preprocessor"></span> |
| 433 | <a name="l00619"></a>00619 <span class="preprocessor">#endif // #ifndef USER_INFO_H</span> |