65 | | <h1>user_info.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef USER_INFO_H</span> |
66 | | <a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define USER_INFO_H</span> |
67 | | <a name="l00003"></a>00003 <span class="preprocessor"></span> |
68 | | <a name="l00004"></a>00004 <span class="preprocessor">#include <stdio.h></span> |
69 | | <a name="l00005"></a>00005 <span class="preprocessor">#include <string></span> |
70 | | <a name="l00006"></a>00006 <span class="preprocessor">#include <typeinfo></span> |
71 | | <a name="l00007"></a>00007 <span class="preprocessor">#include <map></span> |
72 | | <a name="l00008"></a>00008 |
73 | | <a name="l00009"></a>00009 <span class="preprocessor">#include "libconfig/libconfig.h++"</span> |
74 | | <a name="l00010"></a>00010 <span class="preprocessor">#include "../bdmroot.h"</span> |
75 | | <a name="l00011"></a>00011 <span class="preprocessor">#include "itpp/itbase.h"</span> |
76 | | <a name="l00012"></a>00012 |
77 | | <a name="l00013"></a>00013 <span class="preprocessor">#include <stdexcept></span> |
78 | | <a name="l00014"></a>00014 |
79 | | <a name="l00015"></a>00015 <span class="keyword">using</span> std::string; |
80 | | <a name="l00016"></a>00016 <span class="keyword">using namespace </span>std; |
81 | | <a name="l00017"></a>00017 <span class="keyword">using namespace </span>libconfig; |
82 | | <a name="l00018"></a>00018 |
83 | | <a name="l00019"></a>00019 <span class="keyword">namespace </span>bdm |
84 | | <a name="l00020"></a>00020 { |
85 | | <a name="l00021"></a>00021 |
86 | | <a name="l00028"></a>00028 <span class="preprocessor">#ifndef BDMLIB </span> |
87 | | <a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#define UIREGISTER(class_name) template<> const ParticularUI<class_name>& ParticularUI<class_name>::ui = ParticularUI<class_name>(#class_name) </span> |
88 | | <a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#else</span> |
89 | | <a name="l00031"></a>00031 <span class="preprocessor"></span><span class="preprocessor">#define UIREGISTER(class_name)</span> |
90 | | <a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#endif</span> |
91 | | <a name="l00033"></a>00033 <span class="preprocessor"></span> |
92 | | <a name="l00035"></a>00035 <span class="preprocessor">#define ASSERT_UITYPE(SET,TYPE) it_assert_debug(SET.getType()==Setting::TYPE, string("Wrong setting type, see input path \"")+string(SET.getPath())+string("\""))</span> |
93 | | <a name="l00036"></a>00036 <span class="preprocessor"></span> |
94 | | <a name="l00038"></a><a class="code" href="classbdm_1_1UIbuildException.html">00038</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1UIbuildException.html" title="exception used in UI::build if it fails it can be caught and handled - see merger_mex...">UIbuildException</a> : <span class="keyword">public</span> std::invalid_argument { |
95 | | <a name="l00039"></a>00039 <span class="keyword">public</span>: |
96 | | <a name="l00040"></a>00040 <a class="code" href="classbdm_1_1UIbuildException.html" title="exception used in UI::build if it fails it can be caught and handled - see merger_mex...">UIbuildException</a>() : std::invalid_argument(<span class="stringliteral">"class name"</span>) { } |
97 | | <a name="l00041"></a>00041 }; |
98 | | <a name="l00042"></a>00042 |
99 | | <a name="l00065"></a><a class="code" href="classbdm_1_1UIFile.html">00065</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 |
100 | | <a name="l00066"></a>00066 { |
101 | | <a name="l00067"></a>00067 <span class="keyword">public</span>: |
102 | | <a name="l00069"></a>00069 <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>(); |
103 | | <a name="l00070"></a>00070 |
104 | | <a name="l00072"></a>00072 <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">const</span> <span class="keywordtype">string</span> &file_name ); |
105 | | <a name="l00073"></a>00073 |
106 | | <a name="l00075"></a>00075 <span class="keywordtype">void</span> save(<span class="keyword">const</span> <span class="keywordtype">string</span> &file_name); |
| 65 | <h1>user_info.h</h1><a href="user__info_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 |
| 66 | <a name="l00014"></a>00014 <span class="preprocessor">#ifndef USER_INFO_H</span> |
| 67 | <a name="l00015"></a>00015 <span class="preprocessor"></span><span class="preprocessor">#define USER_INFO_H</span> |
| 68 | <a name="l00016"></a>00016 <span class="preprocessor"></span> |
| 69 | <a name="l00017"></a>00017 <span class="preprocessor">#include <stdio.h></span> |
| 70 | <a name="l00018"></a>00018 <span class="preprocessor">#include <string></span> |
| 71 | <a name="l00019"></a>00019 <span class="preprocessor">#include <typeinfo></span> |
| 72 | <a name="l00020"></a>00020 <span class="preprocessor">#include <map></span> |
| 73 | <a name="l00021"></a>00021 <span class="preprocessor">#include <stdexcept></span> |
| 74 | <a name="l00022"></a>00022 |
| 75 | <a name="l00023"></a>00023 <span class="preprocessor">#include "libconfig/libconfig.h++"</span> |
| 76 | <a name="l00024"></a>00024 <span class="preprocessor">#include "../bdmroot.h"</span> |
| 77 | <a name="l00025"></a>00025 <span class="preprocessor">#include "itpp/itbase.h"</span> |
| 78 | <a name="l00026"></a>00026 |
| 79 | <a name="l00027"></a>00027 |
| 80 | <a name="l00028"></a>00028 <span class="keyword">using</span> std::string; |
| 81 | <a name="l00029"></a>00029 <span class="keyword">using namespace </span>std; |
| 82 | <a name="l00030"></a>00030 <span class="keyword">using namespace </span>libconfig; |
| 83 | <a name="l00031"></a>00031 |
| 84 | <a name="l00032"></a>00032 <span class="keyword">namespace </span>bdm |
| 85 | <a name="l00033"></a>00033 { |
| 86 | <a name="l00034"></a>00034 |
| 87 | <a name="l00044"></a>00044 <span class="preprocessor">#ifndef BDMLIB </span> |
| 88 | <a name="l00045"></a><a class="code" href="user__info_8h.html#4f9de2f17e844047726487b99def99c6">00045</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> |
| 89 | <a name="l00046"></a>00046 <span class="preprocessor"></span><span class="preprocessor">#else</span> |
| 90 | <a name="l00047"></a>00047 <span class="preprocessor"></span><span class="preprocessor"> #define UIREGISTER(class_name)</span> |
| 91 | <a name="l00048"></a>00048 <span class="preprocessor"></span><span class="preprocessor">#endif</span> |
| 92 | <a name="l00049"></a>00049 <span class="preprocessor"></span> |
| 93 | <a name="l00051"></a><a class="code" href="classbdm_1_1UIException.html">00051</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1UIException.html" title="Exception prepared for reporting user-info errors which are always related to some...">UIException</a> : <span class="keyword">public</span> std::exception |
| 94 | <a name="l00052"></a>00052 { |
| 95 | <a name="l00053"></a>00053 <span class="keyword">private</span>: |
| 96 | <a name="l00055"></a>00055 <span class="keyword">const</span> <span class="keywordtype">string</span> message; |
| 97 | <a name="l00056"></a>00056 |
| 98 | <a name="l00057"></a>00057 <span class="keyword">public</span>: |
| 99 | <a name="l00059"></a><a class="code" href="classbdm_1_1UIException.html#351bfe4a6e8d0288500e3412313f3301">00059</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> &message, <span class="keyword">const</span> Setting &element ) |
| 100 | <a name="l00060"></a>00060 : message( <span class="stringliteral">"UI error: "</span> + message + <span class="stringliteral">". Check path \""</span> + string(element.getPath()) + <span class="stringliteral">"\"."</span> ) |
| 101 | <a name="l00061"></a>00061 { |
| 102 | <a name="l00062"></a>00062 } |
| 103 | <a name="l00063"></a>00063 |
| 104 | <a name="l00065"></a><a class="code" href="classbdm_1_1UIException.html#691e5563c06a1d4d9e02e01a1a187dae">00065</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> &message, <span class="keyword">const</span> <span class="keywordtype">string</span> &path ) |
| 105 | <a name="l00066"></a>00066 : message( <span class="stringliteral">"UI error: "</span> + message + <span class="stringliteral">"! Check path \""</span> + path + <span class="stringliteral">"\"."</span> ) |
| 106 | <a name="l00067"></a>00067 { |
| 107 | <a name="l00068"></a>00068 } |
| 108 | <a name="l00069"></a>00069 |
| 109 | <a name="l00071"></a><a class="code" href="classbdm_1_1UIException.html#1bf477e4ea19abb638fe5b883f09218e">00071</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() |
| 110 | <a name="l00072"></a>00072 { |
| 111 | <a name="l00073"></a>00073 <span class="keywordflow">return</span> message.c_str(); |
| 112 | <a name="l00074"></a>00074 } |
| 113 | <a name="l00075"></a>00075 }; |
129 | | <a name="l00116"></a>00116 <span class="keyword">public</span>: |
130 | | <a name="l00118"></a>00118 <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 and it is intended for internal purposes only.">UI</a>* <span class="keyword">const</span> ui ); |
131 | | <a name="l00119"></a>00119 |
132 | | <a name="l00121"></a>00121 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class and it is intended for internal purposes only.">UI</a>& retrieve_ui( <span class="keyword">const</span> <span class="keywordtype">string</span> &class_name ); |
133 | | <a name="l00122"></a>00122 |
134 | | <a name="l00124"></a>00124 <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 ); |
135 | | <a name="l00125"></a>00125 }; |
136 | | <a name="l00126"></a>00126 |
137 | | <a name="l00128"></a>00128 <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; |
138 | | <a name="l00129"></a>00129 |
139 | | <a name="l00131"></a>00131 <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 ); |
140 | | <a name="l00132"></a>00132 |
141 | | <a name="l00134"></a>00134 <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 ); |
142 | | <a name="l00135"></a>00135 |
143 | | <a name="l00137"></a>00137 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting( mat& matrix, <span class="keyword">const</span> Setting &element ); |
144 | | <a name="l00139"></a>00139 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting( ivec &vector, <span class="keyword">const</span> Setting &element ); |
145 | | <a name="l00141"></a>00141 <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 (used internally), i.e. expanded RVs - TODO tak proc je ve verejnem...">str</a>, <span class="keyword">const</span> Setting &element ); |
146 | | <a name="l00143"></a>00143 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting( vec &vector, <span class="keyword">const</span> Setting &element ); |
147 | | <a name="l00145"></a>00145 <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 ); |
148 | | <a name="l00147"></a>00147 <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 ); |
149 | | <a name="l00149"></a>00149 <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 ) |
150 | | <a name="l00150"></a>00150 { |
151 | | <a name="l00151"></a>00151 <span class="keyword">const</span> <a class="code" href="classbdm_1_1UI_1_1SettingResolver.html" title="This class serves to expand links used in configuration file.">SettingResolver</a> link( element ); |
152 | | <a name="l00152"></a>00152 |
153 | | <a name="l00153"></a>00153 ASSERT_UITYPE(link.<a class="code" href="classbdm_1_1UI_1_1SettingResolver.html#826d0678854d7ef70895923bdccc1757" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a>,TypeGroup); |
154 | | <a name="l00154"></a>00154 |
155 | | <a name="l00155"></a>00155 <span class="comment">// we get a velue stored in the "class" attribute </span> |
156 | | <a name="l00156"></a>00156 <span class="keywordtype">string</span> class_name; |
157 | | <a name="l00157"></a>00157 <span class="keywordflow">if</span>( !link.<a class="code" href="classbdm_1_1UI_1_1SettingResolver.html#826d0678854d7ef70895923bdccc1757" 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 ) ) |
158 | | <a name="l00158"></a>00158 ui_error( <span class="stringliteral">"the obligatory "</span><span class="stringliteral">"class"</span><span class="stringliteral">" identifier is missing"</span>, link.<a class="code" href="classbdm_1_1UI_1_1SettingResolver.html#826d0678854d7ef70895923bdccc1757" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a> ); |
159 | | <a name="l00159"></a>00159 |
160 | | <a name="l00160"></a>00160 <span class="comment">// then we find a user-info related to this type</span> |
161 | | <a name="l00161"></a>00161 <span class="keyword">const</span> <a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class and it is intended for internal purposes only.">UI</a>& related_UI = MappedUI::retrieve_ui( class_name ); |
162 | | <a name="l00162"></a>00162 |
163 | | <a name="l00163"></a>00163 <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a>* typeless_instance = related_UI.<a class="code" href="classbdm_1_1UI.html#77291f28a4b951522ae5f6a03121b635" title="Method assembling a typeless instance, it is implemented in descendant class ParticularUI&lt;T&gt;...">new_instance</a>(); |
164 | | <a name="l00164"></a>00164 |
165 | | <a name="l00165"></a>00165 instance = NULL; |
166 | | <a name="l00166"></a>00166 <span class="comment">//try catch does not work!!!</span> |
167 | | <a name="l00167"></a>00167 instance = <span class="keyword">dynamic_cast<</span>T*<span class="keyword">></span>(typeless_instance); |
168 | | <a name="l00168"></a>00168 <span class="keywordflow">if</span> (!instance){ |
169 | | <a name="l00169"></a>00169 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UIbuildException.html" title="exception used in UI::build if it fails it can be caught and handled - see merger_mex...">UIbuildException</a>(); |
170 | | <a name="l00170"></a>00170 } |
171 | | <a name="l00171"></a>00171 <span class="comment">// catch(...)</span> |
172 | | <a name="l00172"></a>00172 <span class="comment">// {</span> |
173 | | <a name="l00173"></a>00173 <span class="comment">// TODO pouzit ui_error? </span> |
174 | | <a name="l00174"></a>00174 <span class="comment">// it_error ( "UI error: class " + class_name + " is not a descendant of the desired output class. Try to call the UI::build function with a different type parameter." );</span> |
175 | | <a name="l00175"></a>00175 <span class="comment">// }</span> |
176 | | <a name="l00176"></a>00176 <span class="comment">// </span> |
177 | | <a name="l00177"></a>00177 <span class="keywordflow">try</span> |
178 | | <a name="l00178"></a>00178 { |
179 | | <a name="l00179"></a>00179 instance->from_setting( link.<a class="code" href="classbdm_1_1UI_1_1SettingResolver.html#826d0678854d7ef70895923bdccc1757" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a> ); |
180 | | <a name="l00180"></a>00180 } |
181 | | <a name="l00181"></a>00181 <span class="keywordflow">catch</span>(SettingException xcptn) |
182 | | <a name="l00182"></a>00182 { |
183 | | <a name="l00183"></a>00183 <span class="comment">// TODO pouzit ui_error? </span> |
184 | | <a name="l00184"></a>00184 it_error ( <span class="stringliteral">"UI error: the method "</span> + class_name + <span class="stringliteral">".from_setting(Setting&) has thrown an exception when parsing the setting "</span> + xcptn.getPath() + <span class="stringliteral">". Try to correct this method."</span> ); |
185 | | <a name="l00185"></a>00185 } |
186 | | <a name="l00186"></a>00186 } |
187 | | <a name="l00187"></a>00187 |
188 | | <a name="l00189"></a>00189 <span class="comment">// TODO efektivne jen pro vect, mat a string, pro dalsi je nutne pridat from_setting metodu.. ale to asi necceme</span> |
189 | | <a name="l00190"></a>00190 <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 ) |
190 | | <a name="l00191"></a>00191 { |
191 | | <a name="l00192"></a>00192 <span class="keyword">const</span> <a class="code" href="classbdm_1_1UI_1_1SettingResolver.html" title="This class serves to expand links used in configuration file.">SettingResolver</a> link( element ); |
192 | | <a name="l00193"></a>00193 |
193 | | <a name="l00194"></a>00194 ASSERT_UITYPE(link.<a class="code" href="classbdm_1_1UI_1_1SettingResolver.html#826d0678854d7ef70895923bdccc1757" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a>,TypeList); |
194 | | <a name="l00195"></a>00195 |
195 | | <a name="l00196"></a>00196 <span class="keywordtype">int</span> len = link.<a class="code" href="classbdm_1_1UI_1_1SettingResolver.html#826d0678854d7ef70895923bdccc1757" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a>.getLength(); |
196 | | <a name="l00197"></a>00197 array_to_load.set_length( len ); |
197 | | <a name="l00198"></a>00198 <span class="keywordflow">if</span>( len == 0 ) <span class="keywordflow">return</span>; |
198 | | <a name="l00199"></a>00199 |
199 | | <a name="l00200"></a>00200 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i=0; i < len; i++ ) |
200 | | <a name="l00201"></a>00201 from_setting( array_to_load(i), link.<a class="code" href="classbdm_1_1UI_1_1SettingResolver.html#826d0678854d7ef70895923bdccc1757" title="Reference to a resolved link or to the original Setting in the case it does not contain...">result</a>[i] ); |
201 | | <a name="l00202"></a>00202 } |
| 128 | <a name="l00180"></a><a class="code" href="classbdm_1_1SettingResolver.html">00180</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> |
| 129 | <a name="l00181"></a>00181 { |
| 130 | <a name="l00182"></a>00182 <span class="keyword">private</span>: |
| 131 | <a name="l00184"></a>00184 <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; |
| 132 | <a name="l00185"></a>00185 |
| 133 | <a name="l00191"></a>00191 <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); |
| 134 | <a name="l00192"></a>00192 |
| 135 | <a name="l00193"></a>00193 <span class="keyword">public</span>: |
| 136 | <a name="l00195"></a><a class="code" href="classbdm_1_1SettingResolver.html#adfcd0a81d025c52c8335b6aea07b498">00195</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>; |
| 137 | <a name="l00196"></a>00196 |
| 138 | <a name="l00198"></a>00198 <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 ); |
| 139 | <a name="l00199"></a>00199 |
| 140 | <a name="l00201"></a>00201 <a class="code" href="classbdm_1_1SettingResolver.html#c8b29999710e2db98c1a3979e25e6bbc" title="An opened UIFile file is closed here if necessary.">~SettingResolver</a>(); |
| 141 | <a name="l00202"></a>00202 }; |
203 | | <a name="l00205"></a>00205 <span class="keyword">static</span> <span class="keywordtype">void</span> ui_error( <span class="keywordtype">string</span> message, <span class="keyword">const</span> Setting &element ); |
204 | | <a name="l00206"></a>00206 |
205 | | <a name="l00207"></a>00207 <span class="keyword">protected</span>: |
206 | | <a name="l00209"></a><a class="code" href="classbdm_1_1UI.html#d60234c0673f345424329894b9b0cef8">00209</a> <a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class and it is intended for internal purposes only.">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 ) |
207 | | <a name="l00210"></a>00210 { |
208 | | <a name="l00211"></a>00211 MappedUI::add_class( class_name, class_type_info, <span class="keyword">this</span> ); |
209 | | <a name="l00212"></a>00212 } |
210 | | <a name="l00213"></a>00213 |
211 | | <a name="l00214"></a>00214 <span class="keyword">public</span>: |
212 | | <a name="l00215"></a>00215 |
213 | | <a name="l00234"></a><a class="code" href="classbdm_1_1UI_1_1SettingResolver.html">00234</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1UI_1_1SettingResolver.html" title="This class serves to expand links used in configuration file.">SettingResolver</a> |
214 | | <a name="l00235"></a>00235 { |
215 | | <a name="l00236"></a>00236 <span class="keyword">private</span>: |
216 | | <a name="l00238"></a>00238 <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; |
217 | | <a name="l00239"></a>00239 |
218 | | <a name="l00245"></a>00245 <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); |
219 | | <a name="l00246"></a>00246 |
220 | | <a name="l00247"></a>00247 <span class="keyword">public</span>: |
221 | | <a name="l00249"></a><a class="code" href="classbdm_1_1UI_1_1SettingResolver.html#826d0678854d7ef70895923bdccc1757">00249</a> <span class="keyword">const</span> Setting &result; |
| 143 | <a name="l00211"></a><a class="code" href="classbdm_1_1UI.html">00211</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class and it is intended for internal purposes only.">UI</a> |
| 144 | <a name="l00212"></a>00212 { |
| 145 | <a name="l00213"></a>00213 <span class="keyword">private</span>: |
| 146 | <a name="l00219"></a>00219 <span class="keyword">class </span>MappedUI |
| 147 | <a name="l00220"></a>00220 { |
| 148 | <a name="l00221"></a>00221 <span class="keyword">private</span>: |
| 149 | <a name="l00223"></a>00223 <span class="keyword">typedef</span> map< const string, const UI* const > StringToUIMap; |
| 150 | <a name="l00224"></a>00224 |
| 151 | <a name="l00226"></a>00226 <span class="keyword">typedef</span> map< const type_info * const, const string > TypeInfoToStringMap; |
| 152 | <a name="l00227"></a>00227 |
| 153 | <a name="l00229"></a>00229 <span class="keyword">static</span> StringToUIMap& mapped_strings(); |
| 154 | <a name="l00230"></a>00230 |
| 155 | <a name="l00232"></a>00232 <span class="keyword">static</span> TypeInfoToStringMap& mapped_type_infos(); |
| 156 | <a name="l00233"></a>00233 |
| 157 | <a name="l00235"></a>00235 <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 ); |
| 158 | <a name="l00236"></a>00236 |
| 159 | <a name="l00237"></a>00237 <span class="keyword">public</span>: |
| 160 | <a name="l00239"></a>00239 <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 and it is intended for internal purposes only.">UI</a>* <span class="keyword">const</span> ui ); |
| 161 | <a name="l00240"></a>00240 |
| 162 | <a name="l00242"></a>00242 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class and it is intended for internal purposes only.">UI</a>& retrieve_ui( <span class="keyword">const</span> <span class="keywordtype">string</span> &class_name ); |
| 163 | <a name="l00243"></a>00243 |
| 164 | <a name="l00245"></a>00245 <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 ); |
| 165 | <a name="l00246"></a>00246 }; |
| 166 | <a name="l00247"></a>00247 |
| 167 | <a name="l00249"></a>00249 <span class="keyword">static</span> <span class="keywordtype">void</span> assert_type( <span class="keyword">const</span> Setting &element, Setting::Type type); |
223 | | <a name="l00252"></a>00252 <a class="code" href="classbdm_1_1UI_1_1SettingResolver.html" title="This class serves to expand links used in configuration file.">SettingResolver</a>( <span class="keyword">const</span> Setting &potential_link ); |
224 | | <a name="l00253"></a>00253 |
225 | | <a name="l00255"></a>00255 ~<a class="code" href="classbdm_1_1UI_1_1SettingResolver.html" title="This class serves to expand links used in configuration file.">SettingResolver</a>(); |
226 | | <a name="l00256"></a>00256 }; |
227 | | <a name="l00257"></a>00257 |
228 | | <a name="l00258"></a>00258 <span class="comment">//TODO</span> |
229 | | <a name="l00262"></a>00262 <span class="comment"></span> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> T* build( <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">int</span> index ) |
230 | | <a name="l00263"></a>00263 { |
231 | | <a name="l00264"></a>00264 T* instance; |
232 | | <a name="l00265"></a>00265 from_setting<T>( instance, to_child_setting( element, index ) ); |
233 | | <a name="l00266"></a>00266 <span class="keywordflow">return</span> instance; |
234 | | <a name="l00267"></a>00267 } |
235 | | <a name="l00269"></a><a class="code" href="classbdm_1_1UI.html#6e2da6a142fecf5f21e0bb86a7211cb4">00269</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> T* build( <span class="keyword">const</span> Setting &element ) |
236 | | <a name="l00270"></a>00270 { |
237 | | <a name="l00271"></a>00271 T* instance; |
238 | | <a name="l00272"></a>00272 from_setting<T>( instance, element ); |
239 | | <a name="l00273"></a>00273 <span class="keywordflow">return</span> instance; |
240 | | <a name="l00274"></a>00274 } |
241 | | <a name="l00275"></a>00275 |
242 | | <a name="l00276"></a>00276 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> T* build( <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name ) |
243 | | <a name="l00277"></a>00277 { |
244 | | <a name="l00278"></a>00278 T* instance; |
245 | | <a name="l00279"></a>00279 from_setting<T>( instance, to_child_setting( element, name ) ); |
246 | | <a name="l00280"></a>00280 <span class="keywordflow">return</span> instance; |
247 | | <a name="l00281"></a>00281 } |
248 | | <a name="l00283"></a>00283 |
249 | | <a name="l00287"></a>00287 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</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 ) |
250 | | <a name="l00288"></a>00288 { |
251 | | <a name="l00289"></a>00289 from_setting( instance, to_child_setting( element, name ) ); |
252 | | <a name="l00290"></a>00290 } |
253 | | <a name="l00291"></a>00291 |
254 | | <a name="l00293"></a><a class="code" href="classbdm_1_1UI.html#3d04bb3d7dbcf0da0b4d5d3d5b7df51a">00293</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</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 ) |
255 | | <a name="l00294"></a>00294 { |
256 | | <a name="l00295"></a>00295 from_setting( instance, to_child_setting( element, index ) ); |
257 | | <a name="l00296"></a>00296 } |
258 | | <a name="l00297"></a>00297 |
259 | | <a name="l00299"></a><a class="code" href="classbdm_1_1UI.html#25747ac6d0232aa7102dbb316f65ddce">00299</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</span> <span class="keyword">get</span>( T &instance, <span class="keyword">const</span> Setting &element ) |
260 | | <a name="l00300"></a>00300 { |
261 | | <a name="l00301"></a>00301 from_setting( instance, element ); |
262 | | <a name="l00302"></a>00302 } |
263 | | <a name="l00303"></a>00303 |
264 | | <a name="l00305"></a><a class="code" href="classbdm_1_1UI.html#00bb5f2a328d272b0a3ffbda1a902d54">00305</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</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 ) |
265 | | <a name="l00306"></a>00306 { |
266 | | <a name="l00307"></a>00307 from_setting( array_to_load, to_child_setting( element, name ) ); |
267 | | <a name="l00308"></a>00308 } |
268 | | <a name="l00309"></a>00309 |
269 | | <a name="l00311"></a><a class="code" href="classbdm_1_1UI.html#b6a224b6aea027e167d3d565b39144e0">00311</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</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 ) |
270 | | <a name="l00312"></a>00312 { |
271 | | <a name="l00313"></a>00313 from_setting( array_to_load, to_child_setting( element, index ) ); |
272 | | <a name="l00314"></a>00314 } |
273 | | <a name="l00315"></a>00315 |
274 | | <a name="l00317"></a><a class="code" href="classbdm_1_1UI.html#4fc5efdc58e4e184218b6d5beeb5ceab">00317</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</span> <span class="keyword">get</span>( Array<T> &array_to_load, <span class="keyword">const</span> Setting &element ) |
275 | | <a name="l00318"></a>00318 { |
276 | | <a name="l00319"></a>00319 from_setting( array_to_load, element ); |
277 | | <a name="l00320"></a>00320 } |
278 | | <a name="l00322"></a>00322 |
279 | | <a name="l00323"></a>00323 <span class="keyword">template</span>< <span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</span> save( <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>) |
280 | | <a name="l00324"></a>00324 { |
281 | | <a name="l00325"></a>00325 Setting &<span class="keyword">set</span> = (name == <span class="stringliteral">""</span>) ? element.add( Setting::TypeGroup ) |
282 | | <a name="l00326"></a>00326 : element.add( name, Setting::TypeGroup ); |
283 | | <a name="l00327"></a>00327 |
284 | | <a name="l00328"></a>00328 <span class="keyword">const</span> <span class="keywordtype">string</span> &class_name = MappedUI::retrieve_class_name( &<span class="keyword">typeid</span>(*instance) ); |
285 | | <a name="l00329"></a>00329 |
286 | | <a name="l00330"></a>00330 <span class="comment">// add attribute "class" </span> |
287 | | <a name="l00331"></a>00331 Setting &type = <span class="keyword">set</span>.add( <span class="stringliteral">"class"</span>, Setting::TypeString ); |
288 | | <a name="l00332"></a>00332 type = class_name; |
289 | | <a name="l00333"></a>00333 |
290 | | <a name="l00334"></a>00334 <span class="keywordflow">try</span> |
291 | | <a name="l00335"></a>00335 { |
292 | | <a name="l00336"></a>00336 instance->to_setting( <span class="keyword">set</span> ); |
293 | | <a name="l00337"></a>00337 } |
294 | | <a name="l00338"></a>00338 <span class="keywordflow">catch</span>(SettingException xcptn) |
295 | | <a name="l00339"></a>00339 { |
296 | | <a name="l00340"></a>00340 it_error ( <span class="stringliteral">"UI error: the method "</span> + class_name + <span class="stringliteral">".to_setting(Setting&) has thrown an exception when filling the setting "</span> + xcptn.getPath() + <span class="stringliteral">". Try to correct this method."</span> ); |
297 | | <a name="l00341"></a>00341 } |
298 | | <a name="l00342"></a>00342 } |
299 | | <a name="l00343"></a>00343 |
300 | | <a name="l00345"></a><a class="code" href="classbdm_1_1UI.html#4514f93573a9d9126c506d176fbd3163">00345</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</span> save( <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> ) |
| 169 | <a name="l00252"></a>00252 <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; |
| 170 | <a name="l00253"></a>00253 |
| 171 | <a name="l00255"></a>00255 <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 ); |
| 172 | <a name="l00256"></a>00256 |
| 173 | <a name="l00258"></a>00258 <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 ); |
| 174 | <a name="l00259"></a>00259 |
| 175 | <a name="l00261"></a>00261 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting( mat& matrix, <span class="keyword">const</span> Setting &element ); |
| 176 | <a name="l00263"></a>00263 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting( ivec &vector, <span class="keyword">const</span> Setting &element ); |
| 177 | <a name="l00265"></a>00265 <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 (used internally), i.e. expanded RVs - TODO tak proc je ve verejnem...">str</a>, <span class="keyword">const</span> Setting &element ); |
| 178 | <a name="l00267"></a>00267 <span class="keyword">static</span> <span class="keywordtype">void</span> from_setting( vec &vector, <span class="keyword">const</span> Setting &element ); |
| 179 | <a name="l00269"></a>00269 <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 ); |
| 180 | <a name="l00271"></a>00271 <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 ); |
| 181 | <a name="l00273"></a>00273 <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 ) |
| 182 | <a name="l00274"></a>00274 { |
| 183 | <a name="l00275"></a>00275 <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 ); |
| 184 | <a name="l00276"></a>00276 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); |
| 185 | <a name="l00277"></a>00277 |
| 186 | <a name="l00278"></a>00278 <span class="comment">// we get a value stored in the "class" attribute </span> |
| 187 | <a name="l00279"></a>00279 <span class="keywordtype">string</span> class_name; |
| 188 | <a name="l00280"></a>00280 <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 ) ) |
| 189 | <a name="l00281"></a>00281 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UIException.html" title="Exception prepared for reporting user-info errors which are always related to some...">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> ); |
| 190 | <a name="l00282"></a>00282 |
| 191 | <a name="l00283"></a>00283 <span class="comment">// then we find a user-info related to this type</span> |
| 192 | <a name="l00284"></a>00284 <span class="keyword">const</span> <a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class and it is intended for internal purposes only.">UI</a>& related_UI = MappedUI::retrieve_ui( class_name ); |
| 193 | <a name="l00285"></a>00285 |
| 194 | <a name="l00286"></a>00286 <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a>* typeless_instance = related_UI.<a class="code" href="classbdm_1_1UI.html#77291f28a4b951522ae5f6a03121b635" title="Method assembling a typeless instance, it is implemented in descendant class ParticularUI&lt;T&gt;...">new_instance</a>(); |
| 195 | <a name="l00287"></a>00287 |
| 196 | <a name="l00288"></a>00288 instance = <span class="keyword">dynamic_cast<</span>T*<span class="keyword">></span>(typeless_instance); |
| 197 | <a name="l00289"></a>00289 <span class="keywordflow">if</span> (!instance) |
| 198 | <a name="l00290"></a>00290 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UIException.html" title="Exception prepared for reporting user-info errors which are always related to some...">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> ); |
| 199 | <a name="l00291"></a>00291 |
| 200 | <a name="l00292"></a>00292 <span class="keywordflow">try</span> |
| 201 | <a name="l00293"></a>00293 { |
| 202 | <a name="l00294"></a>00294 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> ); |
| 203 | <a name="l00295"></a>00295 } |
| 204 | <a name="l00296"></a>00296 <span class="keywordflow">catch</span>(SettingException xcptn) |
| 205 | <a name="l00297"></a>00297 { |
| 206 | <a name="l00298"></a>00298 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UIException.html" title="Exception prepared for reporting user-info errors which are always related to some...">UIException</a>( <span class="stringliteral">"the method "</span> + class_name + <span class="stringliteral">".from_setting(Setting&) has thrown an SettingException. Try to correct this method"</span>, xcptn.getPath()); |
| 207 | <a name="l00299"></a>00299 } |
| 208 | <a name="l00300"></a>00300 } |
| 209 | <a name="l00301"></a>00301 |
| 210 | <a name="l00303"></a>00303 <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 ) |
| 211 | <a name="l00304"></a>00304 { |
| 212 | <a name="l00305"></a>00305 <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 ); |
| 213 | <a name="l00306"></a>00306 |
| 214 | <a name="l00307"></a>00307 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); |
| 215 | <a name="l00308"></a>00308 |
| 216 | <a name="l00309"></a>00309 <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(); |
| 217 | <a name="l00310"></a>00310 array_to_load.set_length( len ); |
| 218 | <a name="l00311"></a>00311 <span class="keywordflow">if</span>( len == 0 ) <span class="keywordflow">return</span>; |
| 219 | <a name="l00312"></a>00312 |
| 220 | <a name="l00313"></a>00313 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i=0; i < len; i++ ) |
| 221 | <a name="l00314"></a>00314 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] ); |
| 222 | <a name="l00315"></a>00315 } |
| 223 | <a name="l00316"></a>00316 |
| 224 | <a name="l00317"></a>00317 <span class="keyword">protected</span>: |
| 225 | <a name="l00319"></a><a class="code" href="classbdm_1_1UI.html#d60234c0673f345424329894b9b0cef8">00319</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 ) |
| 226 | <a name="l00320"></a>00320 { |
| 227 | <a name="l00321"></a>00321 MappedUI::add_class( class_name, class_type_info, <span class="keyword">this</span> ); |
| 228 | <a name="l00322"></a>00322 } |
| 229 | <a name="l00323"></a>00323 |
| 230 | <a name="l00324"></a>00324 <span class="keyword">public</span>: |
| 231 | <a name="l00325"></a>00325 |
| 232 | <a name="l00329"></a>00329 |
| 233 | <a name="l00331"></a><a class="code" href="classbdm_1_1UI.html#dda27449f8bd19d54db9ccfb2644e908">00331</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#dda27449f8bd19d54db9ccfb2644e908" title="The new instance of type T* is constructed and initialized with values stored in...">build</a>( <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name ) |
| 234 | <a name="l00332"></a>00332 { |
| 235 | <a name="l00333"></a>00333 T* instance; |
| 236 | <a name="l00334"></a>00334 from_setting<T>( instance, to_child_setting( element, name ) ); |
| 237 | <a name="l00335"></a>00335 <span class="keywordflow">return</span> instance; |
| 238 | <a name="l00336"></a>00336 } |
| 239 | <a name="l00338"></a><a class="code" href="classbdm_1_1UI.html#f0eccc7bbe4b680f3e1cb84b455a1125">00338</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#dda27449f8bd19d54db9ccfb2644e908" title="The new instance of type T* is constructed and initialized with values stored in...">build</a>( <span class="keyword">const</span> Setting &element, <span class="keyword">const</span> <span class="keywordtype">int</span> index ) |
| 240 | <a name="l00339"></a>00339 { |
| 241 | <a name="l00340"></a>00340 T* instance; |
| 242 | <a name="l00341"></a>00341 from_setting<T>( instance, to_child_setting( element, index ) ); |
| 243 | <a name="l00342"></a>00342 <span class="keywordflow">return</span> instance; |
| 244 | <a name="l00343"></a>00343 } |
| 245 | <a name="l00345"></a><a class="code" href="classbdm_1_1UI.html#6e2da6a142fecf5f21e0bb86a7211cb4">00345</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#dda27449f8bd19d54db9ccfb2644e908" title="The new instance of type T* is constructed and initialized with values stored in...">build</a>( <span class="keyword">const</span> Setting &element ) |
302 | | <a name="l00347"></a>00347 ASSERT_UITYPE(element,TypeGroup); |
303 | | <a name="l00348"></a>00348 Setting &list = (name == <span class="stringliteral">""</span>) ? element.add( Setting::TypeList ) |
304 | | <a name="l00349"></a>00349 : element.add( name, Setting::TypeList ); |
305 | | <a name="l00350"></a>00350 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i=0; i<array_to_save.length(); i++ ) |
306 | | <a name="l00351"></a>00351 save( array_to_save(i), list ); |
307 | | <a name="l00352"></a>00352 } |
308 | | <a name="l00353"></a>00353 |
309 | | <a name="l00354"></a>00354 |
310 | | <a name="l00356"></a>00356 <span class="keyword">static</span> <span class="keywordtype">void</span> save( <span class="keyword">const</span> mat &matrix, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ); |
311 | | <a name="l00357"></a>00357 |
312 | | <a name="l00359"></a>00359 <span class="keyword">static</span> <span class="keywordtype">void</span> save( <span class="keyword">const</span> ivec &vec, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ); |
313 | | <a name="l00360"></a>00360 |
314 | | <a name="l00361"></a>00361 <span class="keyword">static</span> <span class="keywordtype">void</span> save( <span class="keyword">const</span> vec &vector, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ); |
315 | | <a name="l00363"></a>00363 <span class="keyword">static</span> <span class="keywordtype">void</span> save( <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> ); |
316 | | <a name="l00364"></a>00364 |
317 | | <a name="l00365"></a>00365 <span class="keyword">static</span> <span class="keywordtype">void</span> save( <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> ); |
318 | | <a name="l00366"></a>00366 |
319 | | <a name="l00367"></a>00367 <span class="keyword">static</span> <span class="keywordtype">void</span> save( <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> ); |
| 247 | <a name="l00347"></a>00347 T* instance; |
| 248 | <a name="l00348"></a>00348 from_setting<T>( instance, element ); |
| 249 | <a name="l00349"></a>00349 <span class="keywordflow">return</span> instance; |
| 250 | <a name="l00350"></a>00350 } |
| 251 | <a name="l00352"></a>00352 |
| 252 | <a name="l00356"></a>00356 |
| 253 | <a name="l00358"></a><a class="code" href="classbdm_1_1UI.html#652bfd23f5052e4f1cb317057d74a3e2">00358</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</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 ) |
| 254 | <a name="l00359"></a>00359 { |
| 255 | <a name="l00360"></a>00360 from_setting( instance, to_child_setting( element, name ) ); |
| 256 | <a name="l00361"></a>00361 } |
| 257 | <a name="l00362"></a>00362 |
| 258 | <a name="l00364"></a><a class="code" href="classbdm_1_1UI.html#3d04bb3d7dbcf0da0b4d5d3d5b7df51a">00364</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">static</span> <span class="keywordtype">void</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 ) |
| 259 | <a name="l00365"></a>00365 { |
| 260 | <a name="l00366"></a>00366 from_setting( instance, to_child_setting( element, index ) ); |
| 261 | <a name="l00367"></a>00367 } |
343 | | <a name="l00399"></a>00399 } |
344 | | <a name="l00400"></a>00400 |
345 | | <a name="l00424"></a>00424 <span class="preprocessor">#endif // #ifndef USER_INFO_H</span> |
| 284 | <a name="l00403"></a>00403 |
| 285 | <a name="l00405"></a><a class="code" href="classbdm_1_1UI.html#c83987949e6a9e79d6e093797ab7d917">00405</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>) |
| 286 | <a name="l00406"></a>00406 { |
| 287 | <a name="l00407"></a>00407 Setting &<span class="keyword">set</span> = (name == <span class="stringliteral">""</span>) ? element.add( Setting::TypeGroup ) |
| 288 | <a name="l00408"></a>00408 : element.add( name, Setting::TypeGroup ); |
| 289 | <a name="l00409"></a>00409 |
| 290 | <a name="l00410"></a>00410 <span class="keyword">const</span> <span class="keywordtype">string</span> &class_name = MappedUI::retrieve_class_name( &<span class="keyword">typeid</span>(*instance) ); |
| 291 | <a name="l00411"></a>00411 |
| 292 | <a name="l00412"></a>00412 <span class="comment">// add attribute "class" </span> |
| 293 | <a name="l00413"></a>00413 Setting &type = <span class="keyword">set</span>.add( <span class="stringliteral">"class"</span>, Setting::TypeString ); |
| 294 | <a name="l00414"></a>00414 type = class_name; |
| 295 | <a name="l00415"></a>00415 |
| 296 | <a name="l00416"></a>00416 <span class="keywordflow">try</span> |
| 297 | <a name="l00417"></a>00417 { |
| 298 | <a name="l00418"></a>00418 instance->to_setting( <span class="keyword">set</span> ); |
| 299 | <a name="l00419"></a>00419 } |
| 300 | <a name="l00420"></a>00420 <span class="keywordflow">catch</span>(SettingException xcptn) |
| 301 | <a name="l00421"></a>00421 { |
| 302 | <a name="l00422"></a>00422 <span class="keywordflow">throw</span> <a class="code" href="classbdm_1_1UIException.html" title="Exception prepared for reporting user-info errors which are always related to some...">UIException</a>( <span class="stringliteral">"the method "</span> + class_name + <span class="stringliteral">".to_setting(Setting&) has thrown an SettingException. Try to correct this method"</span>, xcptn.getPath()); |
| 303 | <a name="l00423"></a>00423 } |
| 304 | <a name="l00424"></a>00424 } |
| 305 | <a name="l00425"></a>00425 |
| 306 | <a name="l00427"></a><a class="code" href="classbdm_1_1UI.html#4514f93573a9d9126c506d176fbd3163">00427</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> Array<T> &array_to_save, Setting &element, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span> ) |
| 307 | <a name="l00428"></a>00428 { |
| 308 | <a name="l00429"></a>00429 assert_type(element,Setting::TypeGroup); |
| 309 | <a name="l00430"></a>00430 Setting &list = (name == <span class="stringliteral">""</span>) ? element.add( Setting::TypeList ) |
| 310 | <a name="l00431"></a>00431 : element.add( name, Setting::TypeList ); |
| 311 | <a name="l00432"></a>00432 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i=0; i<array_to_save.length(); i++ ) |
| 312 | <a name="l00433"></a>00433 <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 ); |
| 313 | <a name="l00434"></a>00434 } |
| 314 | <a name="l00435"></a>00435 |
| 315 | <a name="l00437"></a>00437 <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> ); |
| 316 | <a name="l00438"></a>00438 |
| 317 | <a name="l00440"></a>00440 <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> ); |
| 318 | <a name="l00441"></a>00441 |
| 319 | <a name="l00443"></a>00443 <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> ); |
| 320 | <a name="l00444"></a>00444 |
| 321 | <a name="l00446"></a>00446 <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> ); |
| 322 | <a name="l00447"></a>00447 |
| 323 | <a name="l00449"></a>00449 <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> ); |
| 324 | <a name="l00450"></a>00450 |
| 325 | <a name="l00452"></a>00452 <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> ); |
| 326 | <a name="l00454"></a>00454 |
| 327 | <a name="l00455"></a>00455 }; |
| 328 | <a name="l00456"></a>00456 |
| 329 | <a name="l00457"></a>00457 |
| 330 | <a name="l00459"></a><a class="code" href="classbdm_1_1ParticularUI.html">00459</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" title="The only UI descendant class which is not intended for direct use. It should be accessed...">ParticularUI</a> : <span class="keyword">private</span> <a class="code" href="classbdm_1_1UI.html" title="UI is an abstract class and it is intended for internal purposes only.">UI</a> |
| 331 | <a name="l00460"></a>00460 { |
| 332 | <a name="l00461"></a>00461 <span class="keyword">private</span>: |
| 333 | <a name="l00463"></a>00463 <a class="code" href="classbdm_1_1ParticularUI.html" title="The only UI descendant class which is not intended for direct use. It should be accessed...">ParticularUI<T></a>( <span class="keyword">const</span> <span class="keywordtype">string</span> &class_name) : <a class="code" href="classbdm_1_1UI.html#d60234c0673f345424329894b9b0cef8" title="Default constructor for internal use only, see.">UI</a>( class_name, &<span class="keyword">typeid</span>(T) ) |
| 334 | <a name="l00464"></a><a class="code" href="classbdm_1_1ParticularUI.html#18a208b7549160ae6aeb884dc2bcd90f">00464</a> {}; |
| 335 | <a name="l00465"></a>00465 |
| 336 | <a name="l00466"></a>00466 <span class="keyword">public</span>: |
| 337 | <a name="l00468"></a>00468 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classbdm_1_1ParticularUI.html" title="The only UI descendant class which is not intended for direct use. It should be accessed...">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>; |
| 338 | <a name="l00469"></a>00469 |
| 339 | <a name="l00471"></a><a class="code" href="classbdm_1_1ParticularUI.html#a14fea8c7372a3d0a736e4ed0b617702">00471</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> |
| 340 | <a name="l00472"></a>00472 <span class="keyword"> </span>{ |
| 341 | <a name="l00473"></a>00473 <span class="keywordflow">return</span> <span class="keyword">new</span> T(); |
| 342 | <a name="l00474"></a>00474 } |
| 343 | <a name="l00475"></a>00475 }; |
| 344 | <a name="l00476"></a>00476 |
| 345 | <a name="l00477"></a>00477 } |
| 346 | <a name="l00478"></a>00478 |
| 347 | <a name="l00479"></a>00479 <span class="preprocessor">#endif // #ifndef USER_INFO_H</span> |