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 } |
285 | | <a name="l00414"></a>00414 |
286 | | <a name="l00418"></a>00418 <span class="keyword">template</span><<span class="keyword">class</span> T> |
287 | | <a name="l00419"></a><a class="code" href="classbdm_1_1UI.html#af02851b299aedeb891e30c4807903081">00419</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#af02851b299aedeb891e30c4807903081">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#a88d02c1ffe93033af0f146e8008ab6e6" title="Enum type used to determine whether the data for concrete Settingis is compulsory...">SettingPresence</a> settingPresence = optional ) { |
288 | | <a name="l00420"></a>00420 <span class="keywordflow">if</span> ( element.getLength() <= index ) { |
289 | | <a name="l00421"></a>00421 <span class="keywordflow">if</span> ( settingPresence == optional ) |
290 | | <a name="l00422"></a>00422 <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>(); |
291 | | <a name="l00423"></a>00423 <span class="keywordflow">else</span> { |
292 | | <a name="l00424"></a>00424 stringstream stream; |
293 | | <a name="l00425"></a>00425 stream << index; |
294 | | <a name="l00426"></a>00426 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UISettingException.html">UISettingException</a> ( <span class="stringliteral">"UIException: the compulsory Setting with the index "</span> + stream.str() + <span class="stringliteral">" is missing."</span>, element ); |
295 | | <a name="l00427"></a>00427 } |
296 | | <a name="l00428"></a>00428 } |
297 | | <a name="l00429"></a>00429 |
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 } |
328 | | <a name="l00468"></a>00468 |
329 | | <a name="l00469"></a>00469 from_setting ( instance, to_child_setting ( element, index ) ); |
330 | | <a name="l00470"></a>00470 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
331 | | <a name="l00471"></a>00471 } |
332 | | <a name="l00472"></a>00472 |
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 } |
359 | | <a name="l00510"></a>00510 |
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 } |
380 | | <a name="l00536"></a>00536 |
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 ) ) {}; |
| 270 | <a name="l00391"></a>00391 <span class="keyword">protected</span>: |
| 271 | <a name="l00393"></a><a class="code" href="classbdm_1_1UI.html#ad60234c0673f345424329894b9b0cef8">00393</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 ) { |
| 272 | <a name="l00394"></a>00394 MappedUI::add_class ( class_name, class_type_info, <span class="keyword">this</span> ); |
| 273 | <a name="l00395"></a>00395 } |
| 274 | <a name="l00396"></a>00396 |
| 275 | <a name="l00397"></a>00397 <span class="keyword">public</span>: |
| 276 | <a name="l00398"></a>00398 |
| 277 | <a name="l00400"></a><a class="code" href="classbdm_1_1UI.html#a88d02c1ffe93033af0f146e8008ab6e6">00400</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 } ; |
| 278 | <a name="l00401"></a>00401 |
| 279 | <a name="l00405"></a>00405 |
| 280 | <a name="l00409"></a>00409 <span class="keyword">template</span><<span class="keyword">class</span> T> |
| 281 | <a name="l00410"></a><a class="code" href="classbdm_1_1UI.html#a1f3d45184f803e1256cfc896b43ed2f8">00410</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 ) { |
| 282 | <a name="l00411"></a>00411 <span class="keywordflow">if</span> ( !element.exists ( name ) ) { |
| 283 | <a name="l00412"></a>00412 <span class="keywordflow">if</span> ( settingPresence == optional ) |
| 284 | <a name="l00413"></a>00413 <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>(); |
| 285 | <a name="l00414"></a>00414 <span class="keywordflow">else</span> |
| 286 | <a name="l00415"></a>00415 <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 ); |
| 287 | <a name="l00416"></a>00416 } |
| 288 | <a name="l00417"></a>00417 |
| 289 | <a name="l00418"></a>00418 <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; |
| 290 | <a name="l00419"></a>00419 from_setting<T> ( instance, to_child_setting ( element, name ) ); |
| 291 | <a name="l00420"></a>00420 <span class="keywordflow">return</span> instance; |
| 292 | <a name="l00421"></a>00421 } |
| 293 | <a name="l00422"></a>00422 |
| 294 | <a name="l00426"></a>00426 <span class="keyword">template</span><<span class="keyword">class</span> T> |
| 295 | <a name="l00427"></a><a class="code" href="classbdm_1_1UI.html#af02851b299aedeb891e30c4807903081">00427</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#af02851b299aedeb891e30c4807903081">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#a88d02c1ffe93033af0f146e8008ab6e6" title="Enum type used to determine whether the data for concrete Settingis is compulsory...">SettingPresence</a> settingPresence = optional ) { |
| 296 | <a name="l00428"></a>00428 <span class="keywordflow">if</span> ( element.getLength() <= index ) { |
| 297 | <a name="l00429"></a>00429 <span class="keywordflow">if</span> ( settingPresence == optional ) |
| 298 | <a name="l00430"></a>00430 <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>(); |
| 299 | <a name="l00431"></a>00431 <span class="keywordflow">else</span> { |
| 300 | <a name="l00432"></a>00432 stringstream stream; |
| 301 | <a name="l00433"></a>00433 stream << index; |
| 302 | <a name="l00434"></a>00434 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UISettingException.html">UISettingException</a> ( <span class="stringliteral">"UIException: the compulsory Setting with the index "</span> + stream.str() + <span class="stringliteral">" is missing."</span>, element ); |
| 303 | <a name="l00435"></a>00435 } |
| 304 | <a name="l00436"></a>00436 } |
| 305 | <a name="l00437"></a>00437 |
| 306 | <a name="l00438"></a>00438 <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; |
| 307 | <a name="l00439"></a>00439 from_setting<T> ( instance, to_child_setting ( element, index ) ); |
| 308 | <a name="l00440"></a>00440 <span class="keywordflow">return</span> instance; |
| 309 | <a name="l00441"></a>00441 } |
| 310 | <a name="l00442"></a>00442 |
| 311 | <a name="l00444"></a>00444 |
| 312 | <a name="l00448"></a>00448 |
| 313 | <a name="l00451"></a><a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">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> ( 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 ) { |
| 314 | <a name="l00452"></a>00452 <span class="keywordflow">if</span> ( !element.exists ( name ) ) { |
| 315 | <a name="l00453"></a>00453 <span class="keywordflow">if</span> ( settingPresence == optional ) |
| 316 | <a name="l00454"></a>00454 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
| 317 | <a name="l00455"></a>00455 <span class="keywordflow">else</span> |
| 318 | <a name="l00456"></a>00456 <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 ); |
| 319 | <a name="l00457"></a>00457 } |
| 320 | <a name="l00458"></a>00458 |
| 321 | <a name="l00459"></a>00459 from_setting ( instance, to_child_setting ( element, name ) ); |
| 322 | <a name="l00460"></a>00460 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
| 323 | <a name="l00461"></a>00461 } |
| 324 | <a name="l00462"></a>00462 |
| 325 | <a name="l00465"></a><a class="code" href="classbdm_1_1UI.html#a6fb95ccb13515a3f23080a397dacaa0e">00465</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 ) { |
| 326 | <a name="l00466"></a>00466 <span class="keywordflow">if</span> ( element.getLength() <= index ) { |
| 327 | <a name="l00467"></a>00467 <span class="keywordflow">if</span> ( settingPresence == optional ) |
| 328 | <a name="l00468"></a>00468 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
| 329 | <a name="l00469"></a>00469 <span class="keywordflow">else</span> { |
| 330 | <a name="l00470"></a>00470 stringstream stream; |
| 331 | <a name="l00471"></a>00471 stream << <span class="stringliteral">"UIException: the compulsory Setting with the index "</span> << index << <span class="stringliteral">" is missing."</span>; |
| 332 | <a name="l00472"></a>00472 stream << index; |
| 333 | <a name="l00473"></a>00473 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UISettingException.html">UISettingException</a> (stream.str(), element ); |
| 334 | <a name="l00474"></a>00474 } |
| 335 | <a name="l00475"></a>00475 } |
| 336 | <a name="l00476"></a>00476 |
| 337 | <a name="l00477"></a>00477 from_setting ( instance, to_child_setting ( element, index ) ); |
| 338 | <a name="l00478"></a>00478 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
| 339 | <a name="l00479"></a>00479 } |
| 340 | <a name="l00480"></a>00480 |
| 341 | <a name="l00482"></a><a class="code" href="classbdm_1_1UI.html#a7d2ea138c7285565507fa61fbd9b038f">00482</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 ) { |
| 342 | <a name="l00483"></a>00483 from_setting ( instance, element ); |
| 343 | <a name="l00484"></a>00484 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
| 344 | <a name="l00485"></a>00485 } |
| 345 | <a name="l00487"></a>00487 |
| 346 | <a name="l00491"></a>00491 |
| 347 | <a name="l00494"></a><a class="code" href="classbdm_1_1UI.html#a81ce18ed0bb9993a634db2b99612ad66">00494</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 ) { |
| 348 | <a name="l00495"></a>00495 <span class="keywordflow">if</span> ( !element.exists ( name ) ) |
| 349 | <a name="l00496"></a>00496 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
| 350 | <a name="l00497"></a>00497 |
| 351 | <a name="l00498"></a>00498 from_setting ( array_to_load, to_child_setting ( element, name ) ); |
| 352 | <a name="l00499"></a>00499 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
| 353 | <a name="l00500"></a>00500 } |
| 354 | <a name="l00501"></a>00501 |
| 355 | <a name="l00504"></a><a class="code" href="classbdm_1_1UI.html#a29e450ed5560f81ef2f845e7b1021b71">00504</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 ) { |
| 356 | <a name="l00505"></a>00505 <span class="keywordflow">if</span> ( element.getLength() <= index ) |
| 357 | <a name="l00506"></a>00506 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
| 358 | <a name="l00507"></a>00507 |
| 359 | <a name="l00508"></a>00508 from_setting ( array_to_load, to_child_setting ( element, index ) ); |
| 360 | <a name="l00509"></a>00509 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
| 361 | <a name="l00510"></a>00510 } |
| 362 | <a name="l00511"></a>00511 |
| 363 | <a name="l00513"></a><a class="code" href="classbdm_1_1UI.html#ac9fad8376d2f0857e719511f92f93998">00513</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 ) { |
| 364 | <a name="l00514"></a>00514 from_setting ( array_to_load, element ); |
| 365 | <a name="l00515"></a>00515 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
| 366 | <a name="l00516"></a>00516 } |
| 367 | <a name="l00518"></a>00518 |
| 368 | <a name="l00523"></a>00523 |
| 369 | <a name="l00525"></a><a class="code" href="classbdm_1_1UI.html#ac83987949e6a9e79d6e093797ab7d917">00525</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> ) { |
| 370 | <a name="l00526"></a>00526 Setting &<span class="keyword">set</span> = ( name == <span class="stringliteral">""</span> ) ? element.add ( Setting::TypeGroup ) |
| 371 | <a name="l00527"></a>00527 : element.add ( name, Setting::TypeGroup ); |
| 372 | <a name="l00528"></a>00528 |
| 373 | <a name="l00529"></a>00529 <span class="keyword">const</span> <span class="keywordtype">string</span> &class_name = MappedUI::retrieve_class_name ( &<span class="keyword">typeid</span> ( *instance ) ); |
| 374 | <a name="l00530"></a>00530 |
| 375 | <a name="l00531"></a>00531 <span class="comment">// add attribute "class"</span> |
| 376 | <a name="l00532"></a>00532 Setting &type = <span class="keyword">set</span>.add ( <span class="stringliteral">"class"</span>, Setting::TypeString ); |
| 377 | <a name="l00533"></a>00533 type = class_name; |
| 378 | <a name="l00534"></a>00534 |
| 379 | <a name="l00535"></a>00535 <span class="keywordflow">try</span> { |
| 380 | <a name="l00536"></a>00536 instance->to_setting ( <span class="keyword">set</span> ); |
| 381 | <a name="l00537"></a>00537 } <span class="keywordflow">catch</span> ( SettingException &sttng_xcptn ) { |
| 382 | <a name="l00538"></a>00538 <span class="keywordtype">string</span> msg = <span class="stringliteral">"UIException: method "</span>; |
| 383 | <a name="l00539"></a>00539 msg += class_name; |
| 384 | <a name="l00540"></a>00540 msg += <span class="stringliteral">".to_setting(Setting&) has thrown a SettingException."</span>; |
| 385 | <a name="l00541"></a>00541 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UISettingException.html">UISettingException</a>(msg, sttng_xcptn.getPath()); |
| 386 | <a name="l00542"></a>00542 } |
| 387 | <a name="l00543"></a>00543 } |
| 388 | <a name="l00544"></a>00544 |
| 389 | <a name="l00545"></a>00545 <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> ) { |
| 390 | <a name="l00546"></a>00546 save<T> ( instance.<a class="code" href="classbdm_1_1shared__ptr.html#a37ebcfb6750dd7b5630f1d2354c07a96">get</a>(), element, name ); |
| 391 | <a name="l00547"></a>00547 } |
| 392 | <a name="l00548"></a>00548 |
| 393 | <a name="l00550"></a><a class="code" href="classbdm_1_1UI.html#a4514f93573a9d9126c506d176fbd3163">00550</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> ) { |
| 394 | <a name="l00551"></a>00551 assert_type ( element, Setting::TypeGroup ); |
| 395 | <a name="l00552"></a>00552 Setting &list = ( name == <span class="stringliteral">""</span> ) ? element.add ( Setting::TypeList ) |
| 396 | <a name="l00553"></a>00553 : element.add ( name, Setting::TypeList ); |
| 397 | <a name="l00554"></a>00554 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < array_to_save.length(); i++ ) |
| 398 | <a name="l00555"></a>00555 <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 ); |
| 399 | <a name="l00556"></a>00556 } |
| 400 | <a name="l00557"></a>00557 |
| 401 | <a name="l00559"></a>00559 <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> ); |
| 402 | <a name="l00560"></a>00560 |
| 403 | <a name="l00562"></a>00562 <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> ); |
| 404 | <a name="l00563"></a>00563 |
| 405 | <a name="l00565"></a>00565 <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> ); |
| 406 | <a name="l00566"></a>00566 |
| 407 | <a name="l00568"></a>00568 <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> ); |
| 408 | <a name="l00569"></a>00569 |
| 409 | <a name="l00571"></a>00571 <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> ); |
| 410 | <a name="l00572"></a>00572 |
| 411 | <a name="l00574"></a>00574 <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> ); |
| 412 | <a name="l00576"></a>00576 |
| 413 | <a name="l00577"></a>00577 }; |