97 | | <a name="l00036"></a>00036 } |
98 | | <a name="l00037"></a>00037 }; |
99 | | <a name="l00038"></a>00038 |
100 | | <a name="l00041"></a>00041 |
101 | | <a name="l00043"></a>00043 <span class="keyword">inline</span> vec getvec ( Setting& S ) { |
102 | | <a name="l00044"></a>00044 CHECK_UITYPE ( S,TypeArray ); |
103 | | <a name="l00045"></a>00045 vec tmp; |
104 | | <a name="l00046"></a>00046 tmp.set_size ( S.getLength() ); |
105 | | <a name="l00047"></a>00047 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<S.getLength();i++ ) { |
106 | | <a name="l00048"></a>00048 <span class="keywordflow">switch</span> ( S[i].getType() ) { |
107 | | <a name="l00049"></a>00049 <span class="keywordflow">case</span> Setting::TypeFloat : |
108 | | <a name="l00050"></a>00050 tmp[i]=double ( S[i] );<span class="keywordflow">break</span>; |
109 | | <a name="l00051"></a>00051 <span class="keywordflow">case</span> Setting::TypeInt : |
110 | | <a name="l00052"></a>00052 tmp[i]=int ( S[i] );<span class="keywordflow">break</span>; |
111 | | <a name="l00053"></a>00053 <span class="keywordflow">case</span> Setting::TypeBoolean : |
112 | | <a name="l00054"></a>00054 tmp[i]=bool ( S[i] );<span class="keywordflow">break</span>; |
113 | | <a name="l00055"></a>00055 <span class="keywordflow">default</span>: it_error ( <span class="stringliteral">"libconfig error?"</span> ); |
114 | | <a name="l00056"></a>00056 } |
115 | | <a name="l00057"></a>00057 } |
116 | | <a name="l00058"></a>00058 <span class="keywordflow">return</span> tmp; |
117 | | <a name="l00059"></a>00059 }; |
118 | | <a name="l00060"></a>00060 |
119 | | <a name="l00062"></a>00062 <span class="keyword">inline</span> mat getmat ( Setting& S , <span class="keywordtype">int</span> ncols ) { |
120 | | <a name="l00063"></a>00063 CHECK_UITYPE ( S,TypeArray ); |
121 | | <a name="l00064"></a>00064 mat tmp; |
122 | | <a name="l00065"></a>00065 <span class="keywordtype">int</span> nrows=S.getLength() /ncols; |
123 | | <a name="l00066"></a>00066 <span class="keywordtype">int</span> r=0,c=0; |
124 | | <a name="l00067"></a>00067 tmp.set_size ( nrows, ncols ); |
125 | | <a name="l00068"></a>00068 <span class="comment">// Build matrix row-wise</span> |
126 | | <a name="l00069"></a>00069 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<S.getLength();i++ ) { |
127 | | <a name="l00070"></a>00070 <span class="keywordflow">switch</span> ( S[i].getType() ) { |
128 | | <a name="l00071"></a>00071 <span class="keywordflow">case</span> Setting::TypeFloat : |
129 | | <a name="l00072"></a>00072 tmp ( r,c ) =double ( S[i] );<span class="keywordflow">break</span>; |
130 | | <a name="l00073"></a>00073 <span class="keywordflow">case</span> Setting::TypeInt : |
131 | | <a name="l00074"></a>00074 tmp ( r,c ) =int ( S[i] );<span class="keywordflow">break</span>; |
132 | | <a name="l00075"></a>00075 <span class="keywordflow">case</span> Setting::TypeBoolean : |
133 | | <a name="l00076"></a>00076 tmp ( r,c ) =bool ( S[i] );<span class="keywordflow">break</span>; |
134 | | <a name="l00077"></a>00077 <span class="keywordflow">default</span>: it_error ( <span class="stringliteral">"libconfig error?"</span> ); |
135 | | <a name="l00078"></a>00078 } |
136 | | <a name="l00079"></a>00079 c++; <span class="keywordflow">if</span> ( c==ncols ) {c=0;r++;} |
137 | | <a name="l00080"></a>00080 } |
138 | | <a name="l00081"></a>00081 <span class="keywordflow">return</span> tmp; |
139 | | <a name="l00082"></a>00082 }; |
140 | | <a name="l00083"></a>00083 |
141 | | <a name="l00085"></a>00085 |
142 | | <a name="l00086"></a>00086 <span class="keyword">inline</span> ivec getivec ( Setting& S ) { |
143 | | <a name="l00087"></a>00087 CHECK_UITYPE ( S,TypeArray ); |
144 | | <a name="l00088"></a>00088 ivec tmp; |
145 | | <a name="l00089"></a>00089 tmp.set_size ( S.getLength() ); |
146 | | <a name="l00090"></a>00090 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<S.getLength();i++ ) { |
147 | | <a name="l00091"></a>00091 <span class="keywordflow">switch</span> ( S[i].getType() ) { |
148 | | <a name="l00092"></a>00092 <span class="keywordflow">case</span> Setting::TypeFloat : |
149 | | <a name="l00093"></a>00093 tmp[i]=double ( S[i] );<span class="keywordflow">break</span>; |
150 | | <a name="l00094"></a>00094 <span class="keywordflow">case</span> Setting::TypeInt : |
151 | | <a name="l00095"></a>00095 tmp[i]=int ( S[i] );<span class="keywordflow">break</span>; |
152 | | <a name="l00096"></a>00096 <span class="keywordflow">case</span> Setting::TypeBoolean : |
153 | | <a name="l00097"></a>00097 tmp[i]=bool ( S[i] );<span class="keywordflow">break</span>; |
154 | | <a name="l00098"></a>00098 <span class="keywordflow">default</span>: it_error ( <span class="stringliteral">"libconfig error?"</span> ); |
155 | | <a name="l00099"></a>00099 } |
156 | | <a name="l00100"></a>00100 } |
157 | | <a name="l00101"></a>00101 <span class="keywordflow">return</span> tmp; |
158 | | <a name="l00102"></a>00102 }; |
159 | | <a name="l00103"></a>00103 |
160 | | <a name="l00105"></a>00105 |
161 | | <a name="l00106"></a>00106 <span class="keyword">inline</span> Array<string> get_as ( Setting& S ) { |
162 | | <a name="l00107"></a>00107 CHECK_UITYPE ( S,TypeArray ); |
163 | | <a name="l00108"></a>00108 Array<string> tmp; |
164 | | <a name="l00109"></a>00109 tmp.set_size ( S.getLength() ); |
165 | | <a name="l00110"></a>00110 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<S.getLength();i++ ) {tmp ( i ) = ( <span class="keyword">const</span> <span class="keywordtype">char</span>* ) S[i];} |
166 | | <a name="l00111"></a>00111 <span class="keywordflow">return</span> tmp; |
167 | | <a name="l00112"></a>00112 }; |
168 | | <a name="l00113"></a>00113 |
169 | | <a name="l00115"></a>00115 |
170 | | <a name="l00120"></a><a class="code" href="classbdm_1_1UIbuilder.html">00120</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1UIbuilder.html" title="Builds computational object from a UserInfo structure.">UIbuilder</a> { |
171 | | <a name="l00121"></a>00121 <span class="keyword">protected</span>: |
172 | | <a name="l00122"></a>00122 <span class="keyword">public</span>: |
173 | | <a name="l00124"></a><a class="code" href="classbdm_1_1UIbuilder.html#c75103dd58395644e80f1eea886c656b">00124</a> <a class="code" href="classbdm_1_1UIbuilder.html#c75103dd58395644e80f1eea886c656b" title="Constructor needs to be run only once macro UIREGISTER.">UIbuilder</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &typ ) {__uimap__.insert ( make_pair ( typ,<span class="keyword">this</span> ) );} |
174 | | <a name="l00126"></a>00126 <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1bdmroot.html" title="Root class of BDM objects.">bdmroot</a>* <a class="code" href="classbdm_1_1UIbuilder.html#193cede6302669ff48dfd8ab3b7e31f8" title="Function building the computational object.">build</a> ( Setting &S ) <span class="keyword">const</span> =0; |
175 | | <a name="l00127"></a>00127 }; |
176 | | <a name="l00128"></a>00128 |
177 | | <a name="l00138"></a><a class="code" href="classbdm_1_1UIexternal.html">00138</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1UIexternal.html">UIexternal</a>:<span class="keyword">public</span> <a class="code" href="classbdm_1_1UIbuilder.html" title="Builds computational object from a UserInfo structure.">UIbuilder</a> { |
| 97 | <a name="l00036"></a>00036 setAutoConvert(<span class="keyword">true</span>); |
| 98 | <a name="l00037"></a>00037 } |
| 99 | <a name="l00038"></a>00038 }; |
| 100 | <a name="l00039"></a>00039 |
| 101 | <a name="l00042"></a>00042 |
| 102 | <a name="l00044"></a>00044 <span class="keyword">inline</span> vec getvec ( Setting& S ) { |
| 103 | <a name="l00045"></a>00045 vec vector; |
| 104 | <a name="l00046"></a>00046 <span class="keywordflow">if</span> (S.getType() == Setting::TypeArray) { |
| 105 | <a name="l00047"></a>00047 vector.set_size ( S.getLength() ); |
| 106 | <a name="l00048"></a>00048 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<S.getLength();i++ ) { |
| 107 | <a name="l00049"></a>00049 <span class="keywordflow">switch</span> ( S[i].getType() ) { |
| 108 | <a name="l00050"></a>00050 <span class="keywordflow">case</span> Setting::TypeFloat : |
| 109 | <a name="l00051"></a>00051 vector[i]=double ( S[i] );<span class="keywordflow">break</span>; |
| 110 | <a name="l00052"></a>00052 <span class="keywordflow">case</span> Setting::TypeInt : |
| 111 | <a name="l00053"></a>00053 vector[i]=int ( S[i] );<span class="keywordflow">break</span>; |
| 112 | <a name="l00054"></a>00054 <span class="keywordflow">case</span> Setting::TypeBoolean : |
| 113 | <a name="l00055"></a>00055 vector[i]=bool ( S[i] );<span class="keywordflow">break</span>; |
| 114 | <a name="l00056"></a>00056 <span class="keywordflow">default</span>: <a class="code" href="group__errorhandlingfunc.html#g22d38e98332f9edff88cc501463eedce" title="Abort unconditionally.">it_error</a> ( <span class="stringliteral">"libconfig error?"</span> ); |
| 115 | <a name="l00057"></a>00057 } |
| 116 | <a name="l00058"></a>00058 } |
| 117 | <a name="l00059"></a>00059 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (S.getType() == Setting::TypeGroup) { |
| 118 | <a name="l00060"></a>00060 vector = getvec(S[<span class="stringliteral">"elements"</span>]); |
| 119 | <a name="l00061"></a>00061 <span class="keywordtype">int</span> cols = S[<span class="stringliteral">"cols"</span>]; |
| 120 | <a name="l00062"></a>00062 <span class="keywordflow">if</span> (vector.length() != cols) { |
| 121 | <a name="l00063"></a>00063 <a class="code" href="group__errorhandlingfunc.html#g22d38e98332f9edff88cc501463eedce" title="Abort unconditionally.">it_error</a>(<span class="stringliteral">"requested vector is a matrix"</span>); |
| 122 | <a name="l00064"></a>00064 } |
| 123 | <a name="l00065"></a>00065 } <span class="keywordflow">else</span> { |
| 124 | <a name="l00066"></a>00066 <a class="code" href="group__errorhandlingfunc.html#g22d38e98332f9edff88cc501463eedce" title="Abort unconditionally.">it_error</a>(<span class="stringliteral">"requested vector has invalid type"</span>); |
| 125 | <a name="l00067"></a>00067 } |
| 126 | <a name="l00068"></a>00068 <span class="keywordflow">return</span> vector; |
| 127 | <a name="l00069"></a>00069 }; |
| 128 | <a name="l00070"></a>00070 |
| 129 | <a name="l00072"></a>00072 <span class="keyword">inline</span> mat getmat ( Setting& S , <span class="keywordtype">int</span> ncols ) { |
| 130 | <a name="l00073"></a>00073 CHECK_UITYPE ( S,TypeArray ); |
| 131 | <a name="l00074"></a>00074 mat tmp; |
| 132 | <a name="l00075"></a>00075 <span class="keywordtype">int</span> nrows=S.getLength() /ncols; |
| 133 | <a name="l00076"></a>00076 <span class="keywordtype">int</span> r=0,c=0; |
| 134 | <a name="l00077"></a>00077 tmp.set_size ( nrows, ncols ); |
| 135 | <a name="l00078"></a>00078 <span class="comment">// Build matrix row-wise</span> |
| 136 | <a name="l00079"></a>00079 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<S.getLength();i++ ) { |
| 137 | <a name="l00080"></a>00080 <span class="keywordflow">switch</span> ( S[i].getType() ) { |
| 138 | <a name="l00081"></a>00081 <span class="keywordflow">case</span> Setting::TypeFloat : |
| 139 | <a name="l00082"></a>00082 tmp ( r,c ) =double ( S[i] );<span class="keywordflow">break</span>; |
| 140 | <a name="l00083"></a>00083 <span class="keywordflow">case</span> Setting::TypeInt : |
| 141 | <a name="l00084"></a>00084 tmp ( r,c ) =int ( S[i] );<span class="keywordflow">break</span>; |
| 142 | <a name="l00085"></a>00085 <span class="keywordflow">case</span> Setting::TypeBoolean : |
| 143 | <a name="l00086"></a>00086 tmp ( r,c ) =bool ( S[i] );<span class="keywordflow">break</span>; |
| 144 | <a name="l00087"></a>00087 <span class="keywordflow">default</span>: <a class="code" href="group__errorhandlingfunc.html#g22d38e98332f9edff88cc501463eedce" title="Abort unconditionally.">it_error</a> ( <span class="stringliteral">"libconfig error?"</span> ); |
| 145 | <a name="l00088"></a>00088 } |
| 146 | <a name="l00089"></a>00089 c++; <span class="keywordflow">if</span> ( c==ncols ) {c=0;r++;} |
| 147 | <a name="l00090"></a>00090 } |
| 148 | <a name="l00091"></a>00091 <span class="keywordflow">return</span> tmp; |
| 149 | <a name="l00092"></a>00092 }; |
| 150 | <a name="l00093"></a>00093 |
| 151 | <a name="l00096"></a>00096 <span class="keyword">inline</span> mat getmat (Setting & S) { |
| 152 | <a name="l00097"></a>00097 CHECK_UITYPE (S, TypeGroup); |
| 153 | <a name="l00098"></a>00098 <span class="keywordflow">return</span> getmat(S[<span class="stringliteral">"elements"</span>], S[<span class="stringliteral">"cols"</span>]); |
| 154 | <a name="l00099"></a>00099 } |
| 155 | <a name="l00100"></a>00100 |
| 156 | <a name="l00102"></a>00102 |
| 157 | <a name="l00103"></a>00103 <span class="keyword">inline</span> ivec getivec ( Setting& S ) { |
| 158 | <a name="l00104"></a>00104 CHECK_UITYPE ( S,TypeArray ); |
| 159 | <a name="l00105"></a>00105 ivec tmp; |
| 160 | <a name="l00106"></a>00106 tmp.set_size ( S.getLength() ); |
| 161 | <a name="l00107"></a>00107 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<S.getLength();i++ ) { |
| 162 | <a name="l00108"></a>00108 <span class="keywordflow">switch</span> ( S[i].getType() ) { |
| 163 | <a name="l00109"></a>00109 <span class="keywordflow">case</span> Setting::TypeFloat : |
| 164 | <a name="l00110"></a>00110 tmp[i]=double ( S[i] );<span class="keywordflow">break</span>; |
| 165 | <a name="l00111"></a>00111 <span class="keywordflow">case</span> Setting::TypeInt : |
| 166 | <a name="l00112"></a>00112 tmp[i]=int ( S[i] );<span class="keywordflow">break</span>; |
| 167 | <a name="l00113"></a>00113 <span class="keywordflow">case</span> Setting::TypeBoolean : |
| 168 | <a name="l00114"></a>00114 tmp[i]=bool ( S[i] );<span class="keywordflow">break</span>; |
| 169 | <a name="l00115"></a>00115 <span class="keywordflow">default</span>: <a class="code" href="group__errorhandlingfunc.html#g22d38e98332f9edff88cc501463eedce" title="Abort unconditionally.">it_error</a> ( <span class="stringliteral">"libconfig error?"</span> ); |
| 170 | <a name="l00116"></a>00116 } |
| 171 | <a name="l00117"></a>00117 } |
| 172 | <a name="l00118"></a>00118 <span class="keywordflow">return</span> tmp; |
| 173 | <a name="l00119"></a>00119 }; |
| 174 | <a name="l00120"></a>00120 |
| 175 | <a name="l00122"></a>00122 |
| 176 | <a name="l00123"></a>00123 <span class="keyword">inline</span> <a class="code" href="classitpp_1_1Array.html">Array<string></a> get_as ( Setting& S ) { |
| 177 | <a name="l00124"></a>00124 <span class="comment">//CHECK_UITYPE ( S,TypeArray );</span> |
| 178 | <a name="l00125"></a>00125 <a class="code" href="classitpp_1_1Array.html">Array<string></a> tmp; |
| 179 | <a name="l00126"></a>00126 tmp.<a class="code" href="classitpp_1_1Array.html#dbf76c71f29014a4d53f254e83f3ff1c" title="Resizing an Array&lt;T&gt;.">set_size</a> ( S.getLength() ); |
| 180 | <a name="l00127"></a>00127 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<S.getLength();i++ ) {tmp ( i ) = ( <span class="keyword">const</span> <span class="keywordtype">char</span>* ) S[i];} |
| 181 | <a name="l00128"></a>00128 <span class="keywordflow">return</span> tmp; |
| 182 | <a name="l00129"></a>00129 }; |
| 183 | <a name="l00130"></a>00130 |
| 184 | <a name="l00132"></a>00132 |
| 185 | <a name="l00137"></a><a class="code" href="classbdm_1_1UIbuilder.html">00137</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1UIbuilder.html" title="Builds computational object from a UserInfo structure.">UIbuilder</a> { |
| 186 | <a name="l00138"></a>00138 <span class="keyword">protected</span>: |
179 | | <a name="l00140"></a>00140 <a class="code" href="classbdm_1_1UIexternal.html">UIexternal</a>() :<a class="code" href="classbdm_1_1UIbuilder.html#c75103dd58395644e80f1eea886c656b" title="Constructor needs to be run only once macro UIREGISTER.">UIbuilder</a> ( <span class="stringliteral">"external"</span> ) {} |
180 | | <a name="l00141"></a>00141 <a class="code" href="classbdm_1_1bdmroot.html" title="Root class of BDM objects.">bdmroot</a>* <a class="code" href="classbdm_1_1UIexternal.html#d0daa9edf070e7a01eff13ba02ce84a4" title="Function building the computational object.">build</a> ( Setting &S ) <span class="keyword">const</span>; |
181 | | <a name="l00142"></a>00142 }; |
182 | | <a name="l00143"></a>00143 |
183 | | <a name="l00152"></a><a class="code" href="classbdm_1_1UIinternal.html">00152</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1UIinternal.html">UIinternal</a>:<span class="keyword">public</span> <a class="code" href="classbdm_1_1UIbuilder.html" title="Builds computational object from a UserInfo structure.">UIbuilder</a> { |
184 | | <a name="l00153"></a>00153 <span class="keyword">public</span>: |
185 | | <a name="l00154"></a>00154 <a class="code" href="classbdm_1_1UIinternal.html">UIinternal</a>() :<a class="code" href="classbdm_1_1UIbuilder.html#c75103dd58395644e80f1eea886c656b" title="Constructor needs to be run only once macro UIREGISTER.">UIbuilder</a> ( <span class="stringliteral">"internal"</span> ) {} |
186 | | <a name="l00155"></a>00155 <a class="code" href="classbdm_1_1bdmroot.html" title="Root class of BDM objects.">bdmroot</a>* <a class="code" href="classbdm_1_1UIinternal.html#badb583eaae9f935cda7b410d85d52a6" title="Function building the computational object.">build</a> ( Setting &S ) <span class="keyword">const</span>; |
187 | | <a name="l00156"></a>00156 }; |
188 | | <a name="l00157"></a>00157 |
189 | | <a name="l00159"></a>00159 <span class="keywordtype">void</span> UI_DBG ( Setting &S, <span class="keyword">const</span> <span class="keywordtype">string</span> &spc ); |
190 | | <a name="l00160"></a>00160 |
191 | | <a name="l00162"></a>00162 <span class="keyword">template</span><<span class="keyword">class</span> T> |
192 | | <a name="l00163"></a>00163 <span class="keywordtype">void</span> UIbuild ( Setting &S, T* &ret ) { |
193 | | <a name="l00164"></a>00164 CHECK_UITYPE ( S,TypeGroup ); |
194 | | <a name="l00165"></a>00165 <span class="comment">// Check if field "type" is present, if not it is not a valid UI</span> |
195 | | <a name="l00166"></a>00166 it_assert_debug ( S.exists ( <span class="stringliteral">"type"</span> ), string ( S.getPath() ) +<span class="stringliteral">" is not a valid UI!"</span> ); |
196 | | <a name="l00167"></a>00167 |
197 | | <a name="l00168"></a>00168 <span class="keyword">const</span> <span class="keywordtype">string</span> typ=S[<span class="stringliteral">"type"</span>]; |
198 | | <a name="l00169"></a>00169 <span class="comment">// Find "type" in list of registred UI builders</span> |
199 | | <a name="l00170"></a>00170 UImap::const_iterator iter = __uimap__.find ( typ ); |
200 | | <a name="l00171"></a>00171 <span class="keywordflow">if</span> ( iter == __uimap__.end() ) { |
201 | | <a name="l00172"></a>00172 it_error ( <span class="stringliteral">"UI of type \""</span> + typ + <span class="stringliteral">"\" is not registered!"</span> ); |
202 | | <a name="l00173"></a>00173 } |
203 | | <a name="l00174"></a>00174 |
204 | | <a name="l00175"></a>00175 <span class="comment">//BUILD the result</span> |
205 | | <a name="l00176"></a>00176 <span class="keywordflow">try</span> { |
206 | | <a name="l00177"></a>00177 ret = <span class="keyword">dynamic_cast<</span>T*<span class="keyword">></span> ( iter->second->build ( S ) ); |
207 | | <a name="l00178"></a>00178 } |
208 | | <a name="l00179"></a>00179 <span class="keywordflow">catch</span> UICATCH |
209 | | <a name="l00180"></a>00180 }; |
210 | | <a name="l00181"></a>00181 |
211 | | <a name="l00183"></a>00183 <span class="keyword">template</span><<span class="keyword">class</span> T> |
212 | | <a name="l00184"></a>00184 <span class="keywordtype">void</span> UIcall ( Setting &S, <span class="keywordtype">void</span> ( *func ) ( Setting&, T ), T Tmp ) { |
213 | | <a name="l00185"></a>00185 CHECK_UITYPE ( S,TypeGroup ); |
214 | | <a name="l00186"></a>00186 <span class="comment">// Check if field "type" is present, if not it is not a valid UI</span> |
215 | | <a name="l00187"></a>00187 it_assert_debug ( S.exists ( <span class="stringliteral">"type"</span> ), string ( S.getPath() ) +<span class="stringliteral">" is not a valid UI!"</span> ); |
216 | | <a name="l00188"></a>00188 |
217 | | <a name="l00189"></a>00189 <span class="keyword">const</span> <span class="keywordtype">string</span> typ=S[<span class="stringliteral">"type"</span>]; |
218 | | <a name="l00190"></a>00190 <span class="keywordflow">if</span> ( typ==<span class="stringliteral">"internal"</span> ) { |
219 | | <a name="l00191"></a>00191 <span class="keywordflow">try</span> { |
220 | | <a name="l00192"></a>00192 Setting* Stmp = &S; |
221 | | <a name="l00193"></a>00193 <span class="keywordflow">do</span> {Stmp=& ( Stmp->getParent() );} |
222 | | <a name="l00194"></a>00194 <span class="keywordflow">while</span> ( !Stmp->isRoot() ); |
223 | | <a name="l00195"></a>00195 Setting& intS=Stmp->lookup ( ( <span class="keyword">const</span> <span class="keywordtype">char</span>* ) S[<span class="stringliteral">"path"</span>] ); |
224 | | <a name="l00196"></a>00196 func ( intS, Tmp ); <span class="comment">// <======== calling func</span> |
225 | | <a name="l00197"></a>00197 <span class="keywordflow">return</span>; |
226 | | <a name="l00198"></a>00198 } |
227 | | <a name="l00199"></a>00199 <span class="keywordflow">catch</span> ( ... ) { |
228 | | <a name="l00200"></a>00200 it_error ( <span class="stringliteral">"Internal field "</span> + <span class="keywordtype">string</span> ( S.getPath() ) + <span class="stringliteral">" not valid"</span> ); |
229 | | <a name="l00201"></a>00201 } |
230 | | <a name="l00202"></a>00202 } |
231 | | <a name="l00203"></a>00203 <span class="keywordflow">if</span> ( typ==<span class="stringliteral">"external"</span> ) { |
232 | | <a name="l00204"></a>00204 UIFile C ( S[<span class="stringliteral">"filename"</span>] ); |
233 | | <a name="l00205"></a>00205 <span class="keywordflow">try</span> { |
234 | | <a name="l00206"></a>00206 func ( C.lookup ( ( <span class="keyword">const</span> <span class="keywordtype">char</span>* ) S[<span class="stringliteral">"path"</span>] ), Tmp ); |
235 | | <a name="l00207"></a>00207 } |
236 | | <a name="l00208"></a>00208 <span class="keywordflow">catch</span> ( ... ) { |
237 | | <a name="l00209"></a>00209 it_error ( <span class="stringliteral">"External field "</span> + <span class="keywordtype">string</span> ( S.getPath() ) + <span class="stringliteral">" not valid"</span> ); |
238 | | <a name="l00210"></a>00210 } |
239 | | <a name="l00211"></a>00211 <span class="keywordflow">return</span>; |
240 | | <a name="l00212"></a>00212 } |
241 | | <a name="l00213"></a>00213 |
242 | | <a name="l00214"></a>00214 <span class="comment">// v======================= calling final func</span> |
243 | | <a name="l00215"></a>00215 func ( S, Tmp ); |
244 | | <a name="l00216"></a>00216 }; |
245 | | <a name="l00217"></a>00217 |
246 | | <a name="l00218"></a>00218 } |
247 | | <a name="l00219"></a>00219 <span class="preprocessor">#endif //UIBUILD</span> |
| 188 | <a name="l00141"></a><a class="code" href="classbdm_1_1UIbuilder.html#c75103dd58395644e80f1eea886c656b">00141</a> <a class="code" href="classbdm_1_1UIbuilder.html#c75103dd58395644e80f1eea886c656b" title="Constructor needs to be run only once macro UIREGISTER.">UIbuilder</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &typ ) {__uimap__.insert ( make_pair ( typ,<span class="keyword">this</span> ) );} |
| 189 | <a name="l00143"></a>00143 <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1bdmroot.html" title="Root class of BDM objects.">bdmroot</a>* <a class="code" href="classbdm_1_1UIbuilder.html#193cede6302669ff48dfd8ab3b7e31f8" title="Function building the computational object.">build</a> ( Setting &S ) <span class="keyword">const</span> =0; |
| 190 | <a name="l00145"></a><a class="code" href="classbdm_1_1UIbuilder.html#4cac204ba6c734fdb200513e78495df7">00145</a> <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1UIbuilder.html#4cac204ba6c734fdb200513e78495df7" title="Virtual destructor for future use;.">~UIbuilder</a>(){}; |
| 191 | <a name="l00146"></a>00146 }; |
| 192 | <a name="l00147"></a>00147 |
| 193 | <a name="l00157"></a><a class="code" href="classbdm_1_1UIexternal.html">00157</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1UIexternal.html">UIexternal</a>:<span class="keyword">public</span> <a class="code" href="classbdm_1_1UIbuilder.html" title="Builds computational object from a UserInfo structure.">UIbuilder</a> { |
| 194 | <a name="l00158"></a>00158 <span class="keyword">public</span>: |
| 195 | <a name="l00159"></a>00159 <a class="code" href="classbdm_1_1UIexternal.html">UIexternal</a>() :<a class="code" href="classbdm_1_1UIbuilder.html#c75103dd58395644e80f1eea886c656b" title="Constructor needs to be run only once macro UIREGISTER.">UIbuilder</a> ( <span class="stringliteral">"external"</span> ) {} |
| 196 | <a name="l00160"></a>00160 <a class="code" href="classbdm_1_1bdmroot.html" title="Root class of BDM objects.">bdmroot</a>* <a class="code" href="classbdm_1_1UIexternal.html#d0daa9edf070e7a01eff13ba02ce84a4" title="Function building the computational object.">build</a> ( Setting &S ) <span class="keyword">const</span>; |
| 197 | <a name="l00161"></a>00161 }; |
| 198 | <a name="l00162"></a>00162 |
| 199 | <a name="l00171"></a><a class="code" href="classbdm_1_1UIinternal.html">00171</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1UIinternal.html">UIinternal</a>:<span class="keyword">public</span> <a class="code" href="classbdm_1_1UIbuilder.html" title="Builds computational object from a UserInfo structure.">UIbuilder</a> { |
| 200 | <a name="l00172"></a>00172 <span class="keyword">public</span>: |
| 201 | <a name="l00173"></a>00173 <a class="code" href="classbdm_1_1UIinternal.html">UIinternal</a>() :<a class="code" href="classbdm_1_1UIbuilder.html#c75103dd58395644e80f1eea886c656b" title="Constructor needs to be run only once macro UIREGISTER.">UIbuilder</a> ( <span class="stringliteral">"internal"</span> ) {} |
| 202 | <a name="l00174"></a>00174 <a class="code" href="classbdm_1_1bdmroot.html" title="Root class of BDM objects.">bdmroot</a>* <a class="code" href="classbdm_1_1UIinternal.html#badb583eaae9f935cda7b410d85d52a6" title="Function building the computational object.">build</a> ( Setting &S ) <span class="keyword">const</span>; |
| 203 | <a name="l00175"></a>00175 }; |
| 204 | <a name="l00176"></a>00176 |
| 205 | <a name="l00178"></a>00178 <span class="keywordtype">void</span> UI_DBG ( Setting &S, <span class="keyword">const</span> <span class="keywordtype">string</span> &spc ); |
| 206 | <a name="l00179"></a>00179 |
| 207 | <a name="l00181"></a>00181 <span class="keyword">template</span><<span class="keyword">class</span> T> |
| 208 | <a name="l00182"></a>00182 <span class="keywordtype">void</span> UIbuild ( Setting &S, T* &ret ) { |
| 209 | <a name="l00183"></a>00183 CHECK_UITYPE ( S,TypeGroup ); |
| 210 | <a name="l00184"></a>00184 <span class="comment">// Check if field "type" is present, if not it is not a valid UI</span> |
| 211 | <a name="l00185"></a>00185 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a> ( S.exists ( <span class="stringliteral">"type"</span> ), string ( S.getPath() ) +<span class="stringliteral">" is not a valid UI!"</span> ); |
| 212 | <a name="l00186"></a>00186 |
| 213 | <a name="l00187"></a>00187 <span class="keyword">const</span> <span class="keywordtype">string</span> typ=S[<span class="stringliteral">"type"</span>]; |
| 214 | <a name="l00188"></a>00188 <span class="comment">// Find "type" in list of registred UI builders</span> |
| 215 | <a name="l00189"></a>00189 UImap::const_iterator iter = __uimap__.find ( typ ); |
| 216 | <a name="l00190"></a>00190 <span class="keywordflow">if</span> ( iter == __uimap__.end() ) { |
| 217 | <a name="l00191"></a>00191 <a class="code" href="group__errorhandlingfunc.html#g22d38e98332f9edff88cc501463eedce" title="Abort unconditionally.">it_error</a> ( <span class="stringliteral">"UI of type \""</span> + typ + <span class="stringliteral">"\" is not registered!"</span> ); |
| 218 | <a name="l00192"></a>00192 } |
| 219 | <a name="l00193"></a>00193 |
| 220 | <a name="l00194"></a>00194 <span class="comment">//BUILD the result</span> |
| 221 | <a name="l00195"></a>00195 <span class="keywordflow">try</span> { |
| 222 | <a name="l00196"></a>00196 ret = <span class="keyword">dynamic_cast<</span>T*<span class="keyword">></span> ( iter->second->build ( S ) ); |
| 223 | <a name="l00197"></a>00197 } |
| 224 | <a name="l00198"></a>00198 <span class="keywordflow">catch</span> UICATCH |
| 225 | <a name="l00199"></a>00199 }; |
| 226 | <a name="l00200"></a>00200 |
| 227 | <a name="l00202"></a>00202 <span class="keyword">template</span><<span class="keyword">class</span> T> |
| 228 | <a name="l00203"></a>00203 <span class="keywordtype">void</span> UIcall ( Setting &S, <span class="keywordtype">void</span> ( *func ) ( Setting&, T ), T Tmp ) { |
| 229 | <a name="l00204"></a>00204 CHECK_UITYPE ( S,TypeGroup ); |
| 230 | <a name="l00205"></a>00205 <span class="comment">// Check if field "type" is present, if not it is not a valid UI</span> |
| 231 | <a name="l00206"></a>00206 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a> ( S.exists ( <span class="stringliteral">"type"</span> ), string ( S.getPath() ) +<span class="stringliteral">" is not a valid UI!"</span> ); |
| 232 | <a name="l00207"></a>00207 |
| 233 | <a name="l00208"></a>00208 <span class="keyword">const</span> <span class="keywordtype">string</span> typ=S[<span class="stringliteral">"type"</span>]; |
| 234 | <a name="l00209"></a>00209 <span class="keywordflow">if</span> ( typ==<span class="stringliteral">"internal"</span> ) { |
| 235 | <a name="l00210"></a>00210 <span class="keywordflow">try</span> { |
| 236 | <a name="l00211"></a>00211 Setting* Stmp = &S; |
| 237 | <a name="l00212"></a>00212 <span class="keywordflow">do</span> {Stmp=& ( Stmp->getParent() );} |
| 238 | <a name="l00213"></a>00213 <span class="keywordflow">while</span> ( !Stmp->isRoot() ); |
| 239 | <a name="l00214"></a>00214 Setting& intS=Stmp->lookup ( ( <span class="keyword">const</span> <span class="keywordtype">char</span>* ) S[<span class="stringliteral">"path"</span>] ); |
| 240 | <a name="l00215"></a>00215 func ( intS, Tmp ); <span class="comment">// <======== calling func</span> |
| 241 | <a name="l00216"></a>00216 <span class="keywordflow">return</span>; |
| 242 | <a name="l00217"></a>00217 } |
| 243 | <a name="l00218"></a>00218 <span class="keywordflow">catch</span> ( ... ) { |
| 244 | <a name="l00219"></a>00219 <a class="code" href="group__errorhandlingfunc.html#g22d38e98332f9edff88cc501463eedce" title="Abort unconditionally.">it_error</a> ( <span class="stringliteral">"Internal field "</span> + <span class="keywordtype">string</span> ( S.getPath() ) + <span class="stringliteral">" not valid"</span> ); |
| 245 | <a name="l00220"></a>00220 } |
| 246 | <a name="l00221"></a>00221 } |
| 247 | <a name="l00222"></a>00222 <span class="keywordflow">if</span> ( typ==<span class="stringliteral">"external"</span> ) { |
| 248 | <a name="l00223"></a>00223 UIFile C ( S[<span class="stringliteral">"filename"</span>] ); |
| 249 | <a name="l00224"></a>00224 <span class="keywordflow">try</span> { |
| 250 | <a name="l00225"></a>00225 func ( C.lookup ( ( <span class="keyword">const</span> <span class="keywordtype">char</span>* ) S[<span class="stringliteral">"path"</span>] ), Tmp ); |
| 251 | <a name="l00226"></a>00226 } |
| 252 | <a name="l00227"></a>00227 <span class="keywordflow">catch</span> ( ... ) { |
| 253 | <a name="l00228"></a>00228 <a class="code" href="group__errorhandlingfunc.html#g22d38e98332f9edff88cc501463eedce" title="Abort unconditionally.">it_error</a> ( <span class="stringliteral">"External field "</span> + <span class="keywordtype">string</span> ( S.getPath() ) + <span class="stringliteral">" not valid"</span> ); |
| 254 | <a name="l00229"></a>00229 } |
| 255 | <a name="l00230"></a>00230 <span class="keywordflow">return</span>; |
| 256 | <a name="l00231"></a>00231 } |
| 257 | <a name="l00232"></a>00232 |
| 258 | <a name="l00233"></a>00233 <span class="comment">// v======================= calling final func</span> |
| 259 | <a name="l00234"></a>00234 func ( S, Tmp ); |
| 260 | <a name="l00235"></a>00235 }; |
| 261 | <a name="l00236"></a>00236 |
| 262 | <a name="l00237"></a>00237 } |
| 263 | <a name="l00238"></a>00238 <span class="preprocessor">#endif //UIBUILD</span> |