[259] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
| 2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
---|
[261] | 3 | <title>mixpp: uibuilder.h Source File</title> |
---|
[290] | 4 | <link href="tabs.css" rel="stylesheet" type="text/css"> |
---|
[259] | 5 | <link href="doxygen.css" rel="stylesheet" type="text/css"> |
---|
| 6 | </head><body> |
---|
[290] | 7 | <!-- Generated by Doxygen 1.5.8 --> |
---|
[271] | 8 | <script type="text/javascript"> |
---|
| 9 | <!-- |
---|
| 10 | function changeDisplayState (e){ |
---|
| 11 | var num=this.id.replace(/[^[0-9]/g,''); |
---|
| 12 | var button=this.firstChild; |
---|
| 13 | var sectionDiv=document.getElementById('dynsection'+num); |
---|
| 14 | if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){ |
---|
| 15 | sectionDiv.style.display='block'; |
---|
| 16 | button.src='open.gif'; |
---|
| 17 | }else{ |
---|
| 18 | sectionDiv.style.display='none'; |
---|
| 19 | button.src='closed.gif'; |
---|
| 20 | } |
---|
| 21 | } |
---|
| 22 | function initDynSections(){ |
---|
| 23 | var divs=document.getElementsByTagName('div'); |
---|
| 24 | var sectionCounter=1; |
---|
| 25 | for(var i=0;i<divs.length-1;i++){ |
---|
| 26 | if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){ |
---|
| 27 | var header=divs[i]; |
---|
| 28 | var section=divs[i+1]; |
---|
| 29 | var button=header.firstChild; |
---|
| 30 | if (button!='IMG'){ |
---|
| 31 | divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild); |
---|
| 32 | button=document.createElement('img'); |
---|
| 33 | divs[i].insertBefore(button,divs[i].firstChild); |
---|
| 34 | } |
---|
| 35 | header.style.cursor='pointer'; |
---|
| 36 | header.onclick=changeDisplayState; |
---|
| 37 | header.id='dynheader'+sectionCounter; |
---|
| 38 | button.src='closed.gif'; |
---|
| 39 | section.id='dynsection'+sectionCounter; |
---|
| 40 | section.style.display='none'; |
---|
| 41 | section.style.marginLeft='14px'; |
---|
| 42 | sectionCounter++; |
---|
| 43 | } |
---|
| 44 | } |
---|
| 45 | } |
---|
| 46 | window.onload = initDynSections; |
---|
| 47 | --> |
---|
| 48 | </script> |
---|
[259] | 49 | <div class="navigation" id="top"> |
---|
| 50 | <div class="tabs"> |
---|
| 51 | <ul> |
---|
[271] | 52 | <li><a href="main.html"><span>Main Page</span></a></li> |
---|
[259] | 53 | <li><a href="pages.html"><span>Related Pages</span></a></li> |
---|
| 54 | <li><a href="modules.html"><span>Modules</span></a></li> |
---|
[290] | 55 | <li><a href="annotated.html"><span>Classes</span></a></li> |
---|
[259] | 56 | <li class="current"><a href="files.html"><span>Files</span></a></li> |
---|
| 57 | </ul> |
---|
| 58 | </div> |
---|
[290] | 59 | <div class="tabs"> |
---|
| 60 | <ul> |
---|
| 61 | <li><a href="files.html"><span>File List</span></a></li> |
---|
| 62 | <li><a href="globals.html"><span>File Members</span></a></li> |
---|
| 63 | </ul> |
---|
| 64 | </div> |
---|
[261] | 65 | <h1>uibuilder.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef UIBUILD</span> |
---|
[259] | 66 | <a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define UIBUILD</span> |
---|
| 67 | <a name="l00003"></a>00003 <span class="preprocessor"></span> |
---|
[354] | 68 | <a name="l00004"></a>00004 <span class="preprocessor">#include <itpp/itbase.h></span> |
---|
[261] | 69 | <a name="l00005"></a>00005 <span class="preprocessor">#include "<a class="code" href="libBM_8h.html" title="Bayesian Models (bm) that use Bayes rule to learn from observations.">stat/libBM.h</a>"</span> |
---|
| 70 | <a name="l00006"></a>00006 <span class="preprocessor">#include "libconfig/libconfig.h++"</span> |
---|
[259] | 71 | <a name="l00007"></a>00007 |
---|
[261] | 72 | <a name="l00008"></a>00008 <span class="keyword">namespace </span>bdm { |
---|
[259] | 73 | <a name="l00009"></a>00009 |
---|
[287] | 74 | <a name="l00010"></a>00010 <span class="keyword">using namespace </span>libconfig; |
---|
| 75 | <a name="l00011"></a>00011 <span class="keyword">using namespace </span>std; |
---|
[259] | 76 | <a name="l00012"></a>00012 |
---|
| 77 | <a name="l00013"></a>00013 <span class="preprocessor">#define CHECK_UITYPE(S,Type) it_assert_debug(S.getType()==Setting::Type, string("Wrong input path \"")+string(S.getPath())+string("\""));</span> |
---|
| 78 | <a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define UIREGISTER(UI) UI* UI##_global_instance = new UI();</span> |
---|
| 79 | <a name="l00015"></a>00015 <span class="preprocessor"></span> |
---|
[287] | 80 | <a name="l00017"></a>00017 <span class="preprocessor">#define UICATCH ( SettingTypeException e ) {it_error ( "Setting " +string ( e.getPath() ) +" is of incorrect Type" );} catch ( SettingNotFoundException e ) {it_error ( "Setting " + string ( e.getPath() ) +" was not found" );}</span> |
---|
| 81 | <a name="l00018"></a>00018 <span class="preprocessor"></span> |
---|
| 82 | <a name="l00020"></a>00020 |
---|
| 83 | <a name="l00021"></a>00021 <span class="keyword">class </span>UIbuilder; |
---|
| 84 | <a name="l00023"></a>00023 <span class="keyword">typedef</span> map<const string, const UIbuilder*> UImap; |
---|
| 85 | <a name="l00024"></a>00024 <span class="keyword">extern</span> UImap __uimap__; |
---|
| 86 | <a name="l00025"></a>00025 |
---|
| 87 | <a name="l00026"></a>00026 <span class="keyword">class </span>UIFile : <span class="keyword">public</span> Config { |
---|
| 88 | <a name="l00027"></a>00027 <span class="keyword">public</span>: |
---|
| 89 | <a name="l00028"></a>00028 UIFile ( <span class="keyword">const</span> <span class="keywordtype">char</span> * fname ) :Config() { |
---|
| 90 | <a name="l00029"></a>00029 <span class="keywordflow">try</span>{Config::readFile ( fname );} |
---|
[354] | 91 | <a name="l00030"></a>00030 <span class="keywordflow">catch</span> ( FileIOException f ) {it_error ( <span class="stringliteral">"File "</span> + <span class="keywordtype">string</span> ( fname ) + <span class="stringliteral">" not found"</span> );} |
---|
[287] | 92 | <a name="l00031"></a>00031 <span class="keywordflow">catch</span> ( ParseException& P ) { |
---|
| 93 | <a name="l00032"></a>00032 <span class="keywordtype">char</span> msg[200]; |
---|
| 94 | <a name="l00033"></a>00033 sprintf ( msg,<span class="stringliteral">"Error in file %s on line %d."</span>, fname, P.getLine() ); |
---|
[354] | 95 | <a name="l00034"></a>00034 it_error ( msg ); |
---|
[271] | 96 | <a name="l00035"></a>00035 } |
---|
[353] | 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>; |
---|
[354] | 114 | <a name="l00056"></a>00056 <span class="keywordflow">default</span>: it_error ( <span class="stringliteral">"libconfig error?"</span> ); |
---|
[353] | 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) { |
---|
[354] | 121 | <a name="l00063"></a>00063 it_error(<span class="stringliteral">"requested vector is a matrix"</span>); |
---|
[353] | 122 | <a name="l00064"></a>00064 } |
---|
| 123 | <a name="l00065"></a>00065 } <span class="keywordflow">else</span> { |
---|
[354] | 124 | <a name="l00066"></a>00066 it_error(<span class="stringliteral">"requested vector has invalid type"</span>); |
---|
[353] | 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>; |
---|
[354] | 144 | <a name="l00087"></a>00087 <span class="keywordflow">default</span>: it_error ( <span class="stringliteral">"libconfig error?"</span> ); |
---|
[353] | 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>; |
---|
[354] | 169 | <a name="l00115"></a>00115 <span class="keywordflow">default</span>: it_error ( <span class="stringliteral">"libconfig error?"</span> ); |
---|
[353] | 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 |
---|
[354] | 176 | <a name="l00123"></a>00123 <span class="keyword">inline</span> Array<string> get_as ( Setting& S ) { |
---|
[353] | 177 | <a name="l00124"></a>00124 <span class="comment">//CHECK_UITYPE ( S,TypeArray );</span> |
---|
[354] | 178 | <a name="l00125"></a>00125 Array<string> tmp; |
---|
| 179 | <a name="l00126"></a>00126 tmp.set_size ( S.getLength() ); |
---|
[353] | 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>: |
---|
[287] | 187 | <a name="l00139"></a>00139 <span class="keyword">public</span>: |
---|
[353] | 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> ) {} |
---|
[370] | 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#76b8ff212e2082e2eeaf21694e68d21c" title="Function building the computational object.">build</a> ( Setting &S ) <span class="keyword">const</span>; |
---|
[353] | 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> ) {} |
---|
[370] | 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#73f20e74b814dd7637e25eeb3732f8ca" title="Function building the computational object.">build</a> ( Setting &S ) <span class="keyword">const</span>; |
---|
[353] | 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> |
---|
[354] | 211 | <a name="l00185"></a>00185 it_assert_debug ( S.exists ( <span class="stringliteral">"type"</span> ), string ( S.getPath() ) +<span class="stringliteral">" is not a valid UI!"</span> ); |
---|
[353] | 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() ) { |
---|
[354] | 217 | <a name="l00191"></a>00191 it_error ( <span class="stringliteral">"UI of type \""</span> + typ + <span class="stringliteral">"\" is not registered!"</span> ); |
---|
[353] | 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> |
---|
[354] | 231 | <a name="l00206"></a>00206 it_assert_debug ( S.exists ( <span class="stringliteral">"type"</span> ), string ( S.getPath() ) +<span class="stringliteral">" is not a valid UI!"</span> ); |
---|
[353] | 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> ( ... ) { |
---|
[354] | 244 | <a name="l00219"></a>00219 it_error ( <span class="stringliteral">"Internal field "</span> + <span class="keywordtype">string</span> ( S.getPath() ) + <span class="stringliteral">" not valid"</span> ); |
---|
[353] | 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> ( ... ) { |
---|
[354] | 253 | <a name="l00228"></a>00228 it_error ( <span class="stringliteral">"External field "</span> + <span class="keywordtype">string</span> ( S.getPath() ) + <span class="stringliteral">" not valid"</span> ); |
---|
[353] | 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> |
---|
[259] | 264 | </pre></div></div> |
---|
[375] | 265 | <hr size="1"><address style="text-align: right;"><small>Generated on Mon Jun 15 13:47:07 2009 for mixpp by |
---|
[259] | 266 | <a href="http://www.doxygen.org/index.html"> |
---|
[290] | 267 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address> |
---|
[259] | 268 | </body> |
---|
| 269 | </html> |
---|