root/library/doc/html/loggers_8h_source.html @ 541

Revision 472, 16.4 kB (checked in by mido, 15 years ago)

obnovena dokumentace, vcetne pridani mnoha novych doc-souboru do svn

Line 
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">
3<title>mixpp: loggers.h Source File</title>
4<link href="tabs.css" rel="stylesheet" type="text/css">
5<link href="doxygen.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.5.9 -->
8<script type="text/javascript">
9<!--
10function 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}
22function 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}
46window.onload = initDynSections;
47-->
48</script>
49<div class="navigation" id="top">
50  <div class="tabs">
51    <ul>
52      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
53      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
54      <li><a href="annotated.html"><span>Classes</span></a></li>
55      <li class="current"><a href="files.html"><span>Files</span></a></li>
56    </ul>
57  </div>
58  <div class="tabs">
59    <ul>
60      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
61      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
62    </ul>
63  </div>
64<h1>loggers.h</h1><a href="loggers_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
65<a name="l00013"></a>00013 <span class="preprocessor">#ifndef LGR_H</span>
66<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define LGR_H</span>
67<a name="l00015"></a>00015 <span class="preprocessor"></span>
68<a name="l00016"></a>00016 <span class="preprocessor">#include "<a class="code" href="bdmbase_8h.html" title="Bayesian Models (bm) that use Bayes rule to learn from observations.">bdmbase.h</a>"</span>
69<a name="l00017"></a>00017 <span class="preprocessor">#include "<a class="code" href="user__info_8h.html" title="UI (user info) class for loading/saving objects from/to configuration files. It is...">user_info.h</a>"</span>
70<a name="l00018"></a>00018
71<a name="l00019"></a>00019 <span class="keyword">namespace </span>bdm{
72<a name="l00020"></a>00020 <span class="keyword">using</span> std::string;
73<a name="l00021"></a>00021
74<a name="l00025"></a><a class="code" href="classbdm_1_1memlog.html">00025</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1memlog.html">memlog</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> {
75<a name="l00026"></a>00026
76<a name="l00027"></a>00027 <span class="keyword">protected</span>:
77<a name="l00029"></a><a class="code" href="classbdm_1_1memlog.html#a690ebd91430b5973855c9b4c9cf1b1d">00029</a>         <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1memlog.html#a690ebd91430b5973855c9b4c9cf1b1d" title="Maximum length of vectors stored in memory.">maxlen</a>;
78<a name="l00031"></a><a class="code" href="classbdm_1_1memlog.html#70cec1d3549a82796ad7b6f0d07a4570">00031</a>         <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1memlog.html#70cec1d3549a82796ad7b6f0d07a4570" title="Currect record to be written.">ind</a>;
79<a name="l00033"></a><a class="code" href="classbdm_1_1memlog.html#1fed143162f2de6ef1c1b6557964f24e">00033</a>         Array&lt;mat&gt; <a class="code" href="classbdm_1_1memlog.html#1fed143162f2de6ef1c1b6557964f24e" title="Storage.">vectors</a>;
80<a name="l00035"></a><a class="code" href="classbdm_1_1memlog.html#11fdf8ffca0f509ff637b0c3ac161c1f">00035</a>         <span class="keywordtype">string</span> <a class="code" href="classbdm_1_1memlog.html#11fdf8ffca0f509ff637b0c3ac161c1f" title="name of it file to save results">itfilename</a>;
81<a name="l00036"></a>00036 <span class="keyword">public</span>:
82<a name="l00038"></a><a class="code" href="classbdm_1_1memlog.html#611dda03b3050de2eaa448a59cee9c27">00038</a>         <a class="code" href="classbdm_1_1memlog.html#611dda03b3050de2eaa448a59cee9c27" title="Default constructor.">memlog</a> ( <span class="keywordtype">int</span> maxlen0, <span class="keywordtype">string</span> itf=<span class="stringliteral">""</span> ) : <a class="code" href="classbdm_1_1memlog.html#a690ebd91430b5973855c9b4c9cf1b1d" title="Maximum length of vectors stored in memory.">maxlen</a> ( maxlen0 ),<a class="code" href="classbdm_1_1memlog.html#70cec1d3549a82796ad7b6f0d07a4570" title="Currect record to be written.">ind</a> ( 0 ),<a class="code" href="classbdm_1_1memlog.html#1fed143162f2de6ef1c1b6557964f24e" title="Storage.">vectors</a> ( 0 ),<a class="code" href="classbdm_1_1memlog.html#11fdf8ffca0f509ff637b0c3ac161c1f" title="name of it file to save results">itfilename</a>(itf) {}
83<a name="l00039"></a>00039
84<a name="l00040"></a>00040         <a class="code" href="classbdm_1_1memlog.html">memlog</a>(): <a class="code" href="classbdm_1_1memlog.html#70cec1d3549a82796ad7b6f0d07a4570" title="Currect record to be written.">ind</a> ( 0 ),<a class="code" href="classbdm_1_1memlog.html#1fed143162f2de6ef1c1b6557964f24e" title="Storage.">vectors</a> ( 0 ) {}
85<a name="l00041"></a>00041
86<a name="l00043"></a><a class="code" href="classbdm_1_1memlog.html#d3a8b007f3540523ff3f9910d9089391">00043</a>         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1memlog.html#d3a8b007f3540523ff3f9910d9089391" title="Initialize storage.">init</a>() {
87<a name="l00044"></a>00044                 <span class="keywordtype">int</span> i; <span class="keywordtype">int</span> n =<a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a>.length();
88<a name="l00045"></a>00045                 <a class="code" href="classbdm_1_1memlog.html#1fed143162f2de6ef1c1b6557964f24e" title="Storage.">vectors</a>.set_size ( n );
89<a name="l00046"></a>00046                 <span class="keywordflow">for</span> ( i=0;i&lt;n;i++ ) {<a class="code" href="classbdm_1_1memlog.html#1fed143162f2de6ef1c1b6557964f24e" title="Storage.">vectors</a>(i).set_size (<a class="code" href="classbdm_1_1memlog.html#a690ebd91430b5973855c9b4c9cf1b1d" title="Maximum length of vectors stored in memory.">maxlen</a>,<a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a>(i)._dsize() );}
90<a name="l00047"></a>00047         }
91<a name="l00048"></a><a class="code" href="classbdm_1_1memlog.html#69964f0472e53098528ee41507bdfc77">00048</a>         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1memlog.html#69964f0472e53098528ee41507bdfc77" title="Shifts storage position for another time step.">step</a>() {<span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1memlog.html#70cec1d3549a82796ad7b6f0d07a4570" title="Currect record to be written.">ind</a>&lt;<a class="code" href="classbdm_1_1memlog.html#a690ebd91430b5973855c9b4c9cf1b1d" title="Maximum length of vectors stored in memory.">maxlen</a> ) <a class="code" href="classbdm_1_1memlog.html#70cec1d3549a82796ad7b6f0d07a4570" title="Currect record to be written.">ind</a>++; <span class="keywordflow">else</span> it_error ( <span class="stringliteral">"memlog::ind is too high;"</span> );}
92<a name="l00049"></a><a class="code" href="classbdm_1_1memlog.html#364e58c5d7058776c2a9cfa7d58dad6d">00049</a>         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1memlog.html#364e58c5d7058776c2a9cfa7d58dad6d" title="log this vector">logit</a> ( <span class="keywordtype">int</span> <span class="keywordtype">id</span>, <span class="keyword">const</span> vec &amp;v ) {
93<a name="l00050"></a>00050                 it_assert_debug(<span class="keywordtype">id</span>&lt;<a class="code" href="classbdm_1_1memlog.html#1fed143162f2de6ef1c1b6557964f24e" title="Storage.">vectors</a>.length(),<span class="stringliteral">"Logger was not initialized, run init()."</span>);
94<a name="l00051"></a>00051                 <span class="keywordflow">if</span>(<span class="keywordtype">id</span>&gt;=0){ <a class="code" href="classbdm_1_1memlog.html#1fed143162f2de6ef1c1b6557964f24e" title="Storage.">vectors</a> ( <span class="keywordtype">id</span> ).set_row ( <a class="code" href="classbdm_1_1memlog.html#70cec1d3549a82796ad7b6f0d07a4570" title="Currect record to be written.">ind</a>,v );}
95<a name="l00052"></a>00052         }
96<a name="l00053"></a><a class="code" href="classbdm_1_1memlog.html#2b57dbd3dff49a98c6ce8fccccb170af">00053</a>         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1memlog.html#2b57dbd3dff49a98c6ce8fccccb170af" title="log this double">logit</a> ( <span class="keywordtype">int</span> <span class="keywordtype">id</span>, <span class="keyword">const</span> <span class="keywordtype">double</span> &amp;d ) {
97<a name="l00054"></a>00054                 it_assert_debug(<span class="keywordtype">id</span>&lt;<a class="code" href="classbdm_1_1memlog.html#1fed143162f2de6ef1c1b6557964f24e" title="Storage.">vectors</a>.length(),<span class="stringliteral">"Logger was not initialized, run init()."</span>);
98<a name="l00055"></a>00055                 it_assert_debug(<a class="code" href="classbdm_1_1memlog.html#1fed143162f2de6ef1c1b6557964f24e" title="Storage.">vectors</a>(<span class="keywordtype">id</span>).cols()==1,<span class="stringliteral">"Vector expected"</span>);
99<a name="l00056"></a>00056                 <span class="keywordflow">if</span>(<span class="keywordtype">id</span>&gt;=0){ <a class="code" href="classbdm_1_1memlog.html#1fed143162f2de6ef1c1b6557964f24e" title="Storage.">vectors</a> ( <span class="keywordtype">id</span> ) ( <a class="code" href="classbdm_1_1memlog.html#70cec1d3549a82796ad7b6f0d07a4570" title="Currect record to be written.">ind</a> )=d;}
100<a name="l00057"></a>00057         }
101<a name="l00059"></a>00059         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1memlog.html#6a74b7a3d889607391594279112aef1f" title="Save values into an itfile named after fname.">itsave</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* fname);
102<a name="l00061"></a><a class="code" href="classbdm_1_1memlog.html#39e32f671414c71304e316976ccc37f3">00061</a>         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1memlog.html#39e32f671414c71304e316976ccc37f3" title="Finalize storing information.">finalize</a>() {<span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1memlog.html#11fdf8ffca0f509ff637b0c3ac161c1f" title="name of it file to save results">itfilename</a>.length()&gt;0) <a class="code" href="classbdm_1_1memlog.html#6a74b7a3d889607391594279112aef1f" title="Save values into an itfile named after fname.">itsave</a>(<a class="code" href="classbdm_1_1memlog.html#11fdf8ffca0f509ff637b0c3ac161c1f" title="name of it file to save results">itfilename</a>.c_str());};
103<a name="l00062"></a>00062
104<a name="l00063"></a>00063
105<a name="l00076"></a>00076         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1memlog.html#7352b474bc54c35ab7c9297c5b958629" title="UI for memlog.">from_setting</a>( <span class="keyword">const</span> Setting &amp;<span class="keyword">set</span> );
106<a name="l00077"></a>00077
107<a name="l00078"></a>00078         <span class="comment">// TODO dodelat void to_setting( Setting &amp;set ) const;</span>
108<a name="l00079"></a>00079 };
109<a name="l00080"></a>00080
110<a name="l00081"></a>00081 <a class="code" href="user__info_8h.html#4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a>(memlog);
111<a name="l00082"></a>00082
112<a name="l00090"></a><a class="code" href="classbdm_1_1dirfilelog.html">00090</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1dirfilelog.html" title="Logging into dirfile with buffer in memory.">dirfilelog</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1memlog.html">memlog</a> {
113<a name="l00091"></a>00091
114<a name="l00092"></a>00092 <span class="keyword">protected</span>:
115<a name="l00094"></a><a class="code" href="classbdm_1_1dirfilelog.html#985eb02770f01e25cdceff32ff53a9c5">00094</a>         <span class="keywordtype">string</span> <a class="code" href="classbdm_1_1dirfilelog.html#985eb02770f01e25cdceff32ff53a9c5" title="name of the directory">dirname</a>;
116<a name="l00096"></a><a class="code" href="classbdm_1_1dirfilelog.html#7805040fe1ffa2a048c33980bc995793">00096</a>         Array&lt;string&gt; <a class="code" href="classbdm_1_1dirfilelog.html#7805040fe1ffa2a048c33980bc995793" title="Automatically generated.">scalarnames</a>;
117<a name="l00097"></a>00097 <span class="keyword">public</span>:
118<a name="l00101"></a><a class="code" href="classbdm_1_1dirfilelog.html#15e1c0228c8ecefb372b364742748dff">00101</a>         <a class="code" href="classbdm_1_1dirfilelog.html#15e1c0228c8ecefb372b364742748dff" title="Default constructor.">dirfilelog</a> ( <span class="keywordtype">string</span> dirname0, <span class="keywordtype">int</span> maxlen0 ) : <a class="code" href="classbdm_1_1memlog.html">memlog</a> ( maxlen0 ), <a class="code" href="classbdm_1_1dirfilelog.html#985eb02770f01e25cdceff32ff53a9c5" title="name of the directory">dirname</a> ( dirname0 ), <a class="code" href="classbdm_1_1dirfilelog.html#7805040fe1ffa2a048c33980bc995793" title="Automatically generated.">scalarnames</a> ( 0 ) {}
119<a name="l00102"></a>00102
120<a name="l00103"></a>00103         <a class="code" href="classbdm_1_1dirfilelog.html" title="Logging into dirfile with buffer in memory.">dirfilelog</a>() {}
121<a name="l00104"></a>00104
122<a name="l00106"></a>00106         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1dirfilelog.html#78a3bd8a83cbd6299e279544bc81493d" title="Initialize storage.">init</a>();
123<a name="l00107"></a>00107         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1dirfilelog.html#f79660645d09aa2d8bdd18923a721662" title="Shifts storage position for another time step.">step</a>();
124<a name="l00108"></a>00108         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1dirfilelog.html#521d7ba159f97a0182392df27953804f" title="Finalize storing information.">finalize</a>();
125<a name="l00112"></a>00112         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1dirfilelog.html#f595c0df25f5fa5d8c27ea1e375d9c51" title="Write memory storage to disk.">write_buffers</a> ( <span class="keywordtype">int</span> Len );
126<a name="l00113"></a>00113
127<a name="l00123"></a>00123         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1dirfilelog.html#a32de0f314a30392d69f07458643514e" title="UI for dirfilelog (Kst file format).">from_setting</a>( <span class="keyword">const</span> Setting &amp;<span class="keyword">set</span> );
128<a name="l00124"></a>00124
129<a name="l00125"></a>00125         <span class="comment">// TODO dodelat void to_setting( Setting &amp;set ) const;</span>
130<a name="l00126"></a>00126 };
131<a name="l00127"></a>00127
132<a name="l00128"></a>00128 <a class="code" href="user__info_8h.html#4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a>(dirfilelog);
133<a name="l00129"></a>00129
134<a name="l00130"></a>00130 };
135<a name="l00131"></a>00131 <span class="preprocessor">#endif // LGR_H</span>
136</pre></div></div>
137<hr size="1"><address style="text-align: right;"><small>Generated on Wed Aug 5 00:06:48 2009 for mixpp by&nbsp;
138<a href="http://www.doxygen.org/index.html">
139<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
140</body>
141</html>
Note: See TracBrowser for help on using the browser.