aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/buf__fifo_8cpp-source.html
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--docs/doxygen/nel/buf__fifo_8cpp-source.html746
1 files changed, 746 insertions, 0 deletions
diff --git a/docs/doxygen/nel/buf__fifo_8cpp-source.html b/docs/doxygen/nel/buf__fifo_8cpp-source.html
new file mode 100644
index 00000000..4b8a0f2a
--- /dev/null
+++ b/docs/doxygen/nel/buf__fifo_8cpp-source.html
@@ -0,0 +1,746 @@
+<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<HTML>
+<HEAD>
+ <TITLE>nevrax.org : docs</TITLE>
+ <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css">
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+</HEAD>
+<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
+
+<!-- uplinks -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ </TR>
+</TABLE>
+
+<!-- banner Nevrax -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
+ <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
+</TABLE>
+
+<!-- main table -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+ <!------ Begin Box ------>
+ <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
+ <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
+ <TABLE cellspacing=0 cellpadding=1 border=0>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr>
+ </TABLE>
+ </TD></TR></TABLE></TD></TR></TABLE>
+ <!------ End Box ------>
+
+ </TD>
+ <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+<!-- title -->
+<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
+<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
+</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
+</td></tr></table>
+&nbsp;
+
+<!-- block -->
+<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD>
+ <TD><B>Documentation</B></TD>
+ <TD ALIGN=RIGHT>&nbsp;</td>
+</tr></table>
+<!-- Generated by Doxygen 1.2.14 -->
+<center>
+<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
+<hr><h1>buf_fifo.cpp</h1><a href="buf__fifo_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
+00008 <font class="comment"> *</font>
+00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
+00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
+00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
+00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
+00013 <font class="comment"> * any later version.</font>
+00014 <font class="comment"></font>
+00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
+00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
+00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
+00018 <font class="comment"> * General Public License for more details.</font>
+00019 <font class="comment"></font>
+00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
+00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
+00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
+00023 <font class="comment"> * MA 02111-1307, USA.</font>
+00024 <font class="comment"> */</font>
+00025
+00026 <font class="preprocessor">#include "<a class="code" href="stdmisc_8h.html">stdmisc.h</a>"</font>
+00027
+00028 <font class="preprocessor">#include "<a class="code" href="time__nl_8h.html">nel/misc/time_nl.h</a>"</font>
+00029
+00030 <font class="preprocessor">#include "<a class="code" href="buf__fifo_8h.html">nel/misc/buf_fifo.h</a>"</font>
+00031
+00032 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
+00033
+<a name="l00034"></a><a class="code" href="buf__fifo_8cpp.html#a0">00034</a> <font class="preprocessor">#define DEBUG_FIFO 0</font>
+00035 <font class="preprocessor"></font>
+00036 <font class="keyword">namespace </font>NLMISC {
+00037
+00038
+<a name="l00039"></a><a class="code" href="classNLMISC_1_1CBufFIFO.html#a0">00039</a> CBufFIFO::CBufFIFO() : _Buffer(NULL), _BufferSize(0), _Empty(true), _Head(NULL), _Tail(NULL), _Rewinder(NULL)
+00040 {
+00041 <font class="comment">// reset statistic</font>
+00042 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o6">_BiggestBlock</a> = 0;
+00043 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o7">_SmallestBlock</a> = 999999999;
+00044 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o8">_BiggestBuffer</a> = 0;
+00045 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o9">_SmallestBuffer</a> = 999999999;
+00046 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o10">_Pushed</a> = 0;
+00047 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o11">_Fronted</a> = 0;
+00048 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o12">_Resized</a> = 0;
+00049 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o13">_PushedTime</a> = 0;
+00050 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o14">_FrontedTime</a> = 0;
+00051 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o15">_ResizedTime</a> = 0;
+00052 }
+00053
+<a name="l00054"></a><a class="code" href="classNLMISC_1_1CBufFIFO.html#a1">00054</a> CBufFIFO::~CBufFIFO()
+00055 {
+00056 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a> != NULL)
+00057 {
+00058 <font class="keyword">delete</font> <a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a>;
+00059 <font class="preprocessor">#if DEBUG_FIFO</font>
+00060 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p delete"</font>, <font class="keyword">this</font>);
+00061 <font class="preprocessor">#endif</font>
+00062 <font class="preprocessor"></font> }
+00063 }
+00064
+<a name="l00065"></a><a class="code" href="classNLMISC_1_1CBufFIFO.html#a4">00065</a> <font class="keywordtype">void</font> CBufFIFO::push (<font class="keyword">const</font> uint8 *buffer, uint32 size)
+00066 {
+00067 <font class="comment">// if the buffer is more than 1 meg, there s surely a problem, no?</font>
+00068 <font class="comment">// nlassert( buffer.size() &lt; 1000000 ); // size check in debug mode</font>
+00069
+00070 <a class="code" href="namespaceNLMISC.html#a184">TTicks</a> before = CTime::getPerformanceTime();
+00071
+00072 <font class="preprocessor">#if DEBUG_FIFO</font>
+00073 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p push(%d)"</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>);
+00074 <font class="preprocessor">#endif</font>
+00075 <font class="preprocessor"></font>
+00076 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> &gt; 0 &amp;&amp; <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> &lt; pow(2, <font class="keyword">sizeof</font>(<a class="code" href="classNLMISC_1_1CBufFIFO.html#u0">TFifoSize</a>)*8));
+00077
+00078 <font class="comment">// stat code</font>
+00079 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> &gt; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o6">_BiggestBlock</a>) <a class="code" href="classNLMISC_1_1CBufFIFO.html#o6">_BiggestBlock</a> = <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>;
+00080 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> &lt; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o7">_SmallestBlock</a>) <a class="code" href="classNLMISC_1_1CBufFIFO.html#o7">_SmallestBlock</a> = <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>;
+00081 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o10">_Pushed</a>++;
+00082
+00083 <font class="keywordflow">while</font> (!<a class="code" href="classNLMISC_1_1CBufFIFO.html#c0">canFit</a> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> + <font class="keyword">sizeof</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#u0">TFifoSize</a>)))
+00084 {
+00085 <a class="code" href="classNLMISC_1_1CBufFIFO.html#a11">resize</a>(<a class="code" href="classNLMISC_1_1CBufFIFO.html#o1">_BufferSize</a> * 2);
+00086 }
+00087
+00088 *(<a class="code" href="classNLMISC_1_1CBufFIFO.html#u0">TFifoSize</a> *)<a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> = <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>;
+00089 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> += <font class="keyword">sizeof</font>(TFifoSize);
+00090
+00091 CFastMem::memcpy(<a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a>, buffer, <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>);
+00092
+00093 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> += <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>;
+00094
+00095 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o2">_Empty</a> = <font class="keyword">false</font>;
+00096
+00097 <font class="comment">// stat code</font>
+00098 <a class="code" href="namespaceNLMISC.html#a184">TTicks</a> after = CTime::getPerformanceTime();
+00099 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o13">_PushedTime</a> += after - before;
+00100
+00101 <font class="preprocessor">#if DEBUG_FIFO</font>
+00102 <font class="preprocessor"></font> <a class="code" href="classNLMISC_1_1CBufFIFO.html#a15">display</a> ();
+00103 <font class="preprocessor">#endif</font>
+00104 <font class="preprocessor"></font>}
+00105
+<a name="l00106"></a><a class="code" href="classNLMISC_1_1CBufFIFO.html#a5">00106</a> <font class="keywordtype">void</font> CBufFIFO::push(<font class="keyword">const</font> std::vector&lt;uint8&gt; &amp;buffer1, <font class="keyword">const</font> std::vector&lt;uint8&gt; &amp;buffer2)
+00107 {
+00108 <a class="code" href="namespaceNLMISC.html#a184">TTicks</a> before = CTime::getPerformanceTime();
+00109
+00110 <a class="code" href="classNLMISC_1_1CBufFIFO.html#u0">TFifoSize</a> <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> = buffer1.size() + buffer2.size ();
+00111
+00112 <font class="preprocessor">#if DEBUG_FIFO</font>
+00113 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p push2(%d)"</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>);
+00114 <font class="preprocessor">#endif</font>
+00115 <font class="preprocessor"></font>
+00116 <a class="code" href="debug_8h.html#a6">nlassert</a>((buffer1.size() + buffer2.size ()) &gt; 0 &amp;&amp; (buffer1.size() + buffer2.size ()) &lt; pow(2, <font class="keyword">sizeof</font>(<a class="code" href="classNLMISC_1_1CBufFIFO.html#u0">TFifoSize</a>)*8));
+00117
+00118 <font class="comment">// avoid too big fifo</font>
+00119 <font class="keywordflow">if</font> (this-&gt;<a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>() &gt; 10000000)
+00120 {
+00121 <font class="keywordflow">throw</font> Exception (<font class="stringliteral">"CBufFIFO::push(): stack full (more than 10mb)"</font>);
+00122 }
+00123
+00124
+00125 <font class="comment">// stat code</font>
+00126 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> &gt; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o6">_BiggestBlock</a>) <a class="code" href="classNLMISC_1_1CBufFIFO.html#o6">_BiggestBlock</a> = <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>;
+00127 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> &lt; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o7">_SmallestBlock</a>) <a class="code" href="classNLMISC_1_1CBufFIFO.html#o7">_SmallestBlock</a> = <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>;
+00128
+00129 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o10">_Pushed</a>++;
+00130
+00131 <font class="comment">// resize while the buffer is enough big to accept the block</font>
+00132 <font class="keywordflow">while</font> (!<a class="code" href="classNLMISC_1_1CBufFIFO.html#c0">canFit</a> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> + <font class="keyword">sizeof</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#u0">TFifoSize</a>)))
+00133 {
+00134 <a class="code" href="classNLMISC_1_1CBufFIFO.html#a11">resize</a>(<a class="code" href="classNLMISC_1_1CBufFIFO.html#o1">_BufferSize</a> * 2);
+00135 }
+00136
+00137 <font class="comment">// store the size of the block</font>
+00138 *(<a class="code" href="classNLMISC_1_1CBufFIFO.html#u0">TFifoSize</a> *)<a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> = <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>;
+00139 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> += <font class="keyword">sizeof</font>(TFifoSize);
+00140
+00141 <font class="comment">// store the block itself</font>
+00142 CFastMem::memcpy(<a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a>, &amp;(buffer1[0]), buffer1.size ());
+00143 CFastMem::memcpy(<a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> + buffer1.size(), &amp;(buffer2[0]), buffer2.size ());
+00144 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> += <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>;
+00145
+00146 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o2">_Empty</a> = <font class="keyword">false</font>;
+00147
+00148 <font class="comment">// stat code</font>
+00149 <a class="code" href="namespaceNLMISC.html#a184">TTicks</a> after = CTime::getPerformanceTime();
+00150 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o13">_PushedTime</a> += after - before;
+00151
+00152 <font class="preprocessor">#if DEBUG_FIFO</font>
+00153 <font class="preprocessor"></font> <a class="code" href="classNLMISC_1_1CBufFIFO.html#a15">display</a> ();
+00154 <font class="preprocessor">#endif</font>
+00155 <font class="preprocessor"></font>}
+00156
+<a name="l00157"></a><a class="code" href="classNLMISC_1_1CBufFIFO.html#a10">00157</a> <font class="keywordtype">void</font> CBufFIFO::pop ()
+00158 {
+00159 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#a12">empty</a> ())
+00160 {
+00161 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"Try to pop an empty fifo!"</font>);
+00162 <font class="keywordflow">return</font>;
+00163 }
+00164
+00165 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> != NULL &amp;&amp; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a> == <a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a>)
+00166 {
+00167 <font class="preprocessor">#if DEBUG_FIFO</font>
+00168 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p pop rewind!"</font>, <font class="keyword">this</font>);
+00169 <font class="preprocessor">#endif</font>
+00170 <font class="preprocessor"></font>
+00171 <font class="comment">// need to rewind</font>
+00172 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a> = <a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a>;
+00173 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> = NULL;
+00174 }
+00175
+00176 <a class="code" href="classNLMISC_1_1CBufFIFO.html#u0">TFifoSize</a> <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> = *(<a class="code" href="classNLMISC_1_1CBufFIFO.html#u0">TFifoSize</a> *)<a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a>;
+00177
+00178 <font class="preprocessor">#if DEBUG_FIFO</font>
+00179 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p pop(%d)"</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>);
+00180 <font class="preprocessor">#endif</font>
+00181 <font class="preprocessor"></font>
+00182 <font class="preprocessor">#ifdef NL_DEBUG</font>
+00183 <font class="preprocessor"></font> <font class="comment">// clear the message to be sure user doesn't use it anymore</font>
+00184 memset (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a>, <font class="charliteral">'-'</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> + <font class="keyword">sizeof</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#u0">TFifoSize</a>));
+00185 <font class="preprocessor">#endif</font>
+00186 <font class="preprocessor"></font>
+00187 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a> += <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> + <font class="keyword">sizeof</font> (TFifoSize);
+00188
+00189 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a> == <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a>) <a class="code" href="classNLMISC_1_1CBufFIFO.html#o2">_Empty</a> = <font class="keyword">true</font>;
+00190
+00191 <font class="preprocessor">#if DEBUG_FIFO</font>
+00192 <font class="preprocessor"></font> <a class="code" href="classNLMISC_1_1CBufFIFO.html#a15">display</a> ();
+00193 <font class="preprocessor">#endif</font>
+00194 <font class="preprocessor"></font>}
+00195
+<a name="l00196"></a><a class="code" href="classNLMISC_1_1CBufFIFO.html#a9">00196</a> uint8 CBufFIFO::frontLast ()
+00197 {
+00198 uint8 *tail = <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a>;
+00199
+00200 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#a12">empty</a> ())
+00201 {
+00202 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"Try to get the front of an empty fifo!"</font>);
+00203 <font class="keywordflow">return</font> 0;
+00204 }
+00205
+00206 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> != NULL &amp;&amp; tail == <a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a>)
+00207 {
+00208 <font class="preprocessor">#if DEBUG_FIFO</font>
+00209 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p front rewind!"</font>, <font class="keyword">this</font>);
+00210 <font class="preprocessor">#endif</font>
+00211 <font class="preprocessor"></font>
+00212 <font class="comment">// need to rewind</font>
+00213 tail = <a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a>;
+00214 }
+00215
+00216 <a class="code" href="classNLMISC_1_1CBufFIFO.html#u0">TFifoSize</a> <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> = *(<a class="code" href="classNLMISC_1_1CBufFIFO.html#u0">TFifoSize</a> *)tail;
+00217
+00218 <font class="preprocessor">#if DEBUG_FIFO</font>
+00219 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p frontLast() returns %d "</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>, *(tail+<font class="keyword">sizeof</font>(<a class="code" href="classNLMISC_1_1CBufFIFO.html#u0">TFifoSize</a>)+<a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>-1));
+00220 <font class="preprocessor">#endif</font>
+00221 <font class="preprocessor"></font>
+00222 <font class="keywordflow">return</font> *(tail+<font class="keyword">sizeof</font>(TFifoSize)+<a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>-1);
+00223 }
+00224
+00225
+<a name="l00226"></a><a class="code" href="classNLMISC_1_1CBufFIFO.html#a6">00226</a> <font class="keywordtype">void</font> CBufFIFO::front (vector&lt;uint8&gt; &amp;buffer)
+00227 {
+00228 uint8 *tmpbuffer;
+00229 uint32 <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>;
+00230
+00231 buffer.clear ();
+00232
+00233 <a class="code" href="classNLMISC_1_1CBufFIFO.html#a6">front</a> (tmpbuffer, <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>);
+00234
+00235 buffer.resize (<a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>);
+00236
+00237 CFastMem::memcpy (&amp;(buffer[0]), tmpbuffer, <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>);
+00238
+00239 <font class="comment">/* TTicks before = CTime::getPerformanceTime ();</font>
+00240 <font class="comment"></font>
+00241 <font class="comment"> uint8 *tail = _Tail;</font>
+00242 <font class="comment"> </font>
+00243 <font class="comment"> buffer.clear ();</font>
+00244 <font class="comment"></font>
+00245 <font class="comment"> if (empty ())</font>
+00246 <font class="comment"> {</font>
+00247 <font class="comment"> nlwarning("Try to get the front of an empty fifo!");</font>
+00248 <font class="comment"> return;</font>
+00249 <font class="comment"> }</font>
+00250 <font class="comment"></font>
+00251 <font class="comment"> _Fronted++;</font>
+00252 <font class="comment"> </font>
+00253 <font class="comment"> if (_Rewinder != NULL &amp;&amp; tail == _Rewinder)</font>
+00254 <font class="comment"> {</font>
+00255 <font class="comment">#if DEBUG_FIFO</font>
+00256 <font class="comment"> nldebug("%p front rewind!", this);</font>
+00257 <font class="comment">#endif</font>
+00258 <font class="comment"></font>
+00259 <font class="comment"> // need to rewind</font>
+00260 <font class="comment"> tail = _Buffer;</font>
+00261 <font class="comment"> }</font>
+00262 <font class="comment"></font>
+00263 <font class="comment"> TFifoSize size = *(TFifoSize *)tail;</font>
+00264 <font class="comment"></font>
+00265 <font class="comment">#if DEBUG_FIFO</font>
+00266 <font class="comment"> nldebug("%p front(%d)", this, size);</font>
+00267 <font class="comment">#endif</font>
+00268 <font class="comment"></font>
+00269 <font class="comment"> tail += sizeof (TFifoSize);</font>
+00270 <font class="comment"></font>
+00271 <font class="comment"> buffer.resize (size);</font>
+00272 <font class="comment"></font>
+00273 <font class="comment"> CFastMem::memcpy (&amp;(buffer[0]), tail, size);</font>
+00274 <font class="comment"></font>
+00275 <font class="comment"> // stat code</font>
+00276 <font class="comment"> TTicks after = CTime::getPerformanceTime ();</font>
+00277 <font class="comment"> _FrontedTime += after - before;</font>
+00278 <font class="comment"></font>
+00279 <font class="comment">#if DEBUG_FIFO</font>
+00280 <font class="comment"> display ();</font>
+00281 <font class="comment">#endif</font>
+00282 <font class="comment">*/</font>}
+00283
+00284
+<a name="l00285"></a><a class="code" href="classNLMISC_1_1CBufFIFO.html#a7">00285</a> <font class="keywordtype">void</font> CBufFIFO::front (<a class="code" href="classNLMISC_1_1CMemStream.html">NLMISC::CMemStream</a> &amp;buffer)
+00286 {
+00287 uint8 *tmpbuffer;
+00288 uint32 <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>;
+00289
+00290 buffer.<a class="code" href="classNLMISC_1_1CMemStream.html#a9">clear</a> ();
+00291
+00292 <a class="code" href="classNLMISC_1_1CBufFIFO.html#a6">front</a> (tmpbuffer, <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>);
+00293
+00294 buffer.<a class="code" href="classNLMISC_1_1CMemStream.html#a13">fill</a> (tmpbuffer, <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>);
+00295
+00296 <font class="comment">/*</font>
+00297 <font class="comment"> TTicks before = CTime::getPerformanceTime ();</font>
+00298 <font class="comment"></font>
+00299 <font class="comment"> uint8 *tail = _Tail;</font>
+00300 <font class="comment"> </font>
+00301 <font class="comment"> buffer.clear ();</font>
+00302 <font class="comment"></font>
+00303 <font class="comment"> if (empty ())</font>
+00304 <font class="comment"> {</font>
+00305 <font class="comment"> nlwarning("Try to get the front of an empty fifo!");</font>
+00306 <font class="comment"> return;</font>
+00307 <font class="comment"> }</font>
+00308 <font class="comment"></font>
+00309 <font class="comment"> _Fronted++;</font>
+00310 <font class="comment"> </font>
+00311 <font class="comment"> if (_Rewinder != NULL &amp;&amp; tail == _Rewinder)</font>
+00312 <font class="comment"> {</font>
+00313 <font class="comment">#if DEBUG_FIFO</font>
+00314 <font class="comment"> nldebug("%p front rewind!", this);</font>
+00315 <font class="comment">#endif</font>
+00316 <font class="comment"></font>
+00317 <font class="comment"> // need to rewind</font>
+00318 <font class="comment"> tail = _Buffer;</font>
+00319 <font class="comment"> }</font>
+00320 <font class="comment"></font>
+00321 <font class="comment"> TFifoSize size = *(TFifoSize *)tail;</font>
+00322 <font class="comment"></font>
+00323 <font class="comment">#if DEBUG_FIFO</font>
+00324 <font class="comment"> nldebug("%p front(%d)", this, size);</font>
+00325 <font class="comment">#endif</font>
+00326 <font class="comment"></font>
+00327 <font class="comment"> tail += sizeof (TFifoSize);</font>
+00328 <font class="comment"></font>
+00329 <font class="comment"> //buffer.resize (size);</font>
+00330 <font class="comment"> //CFastMem::memcpy (&amp;(buffer[0]), tail, size);</font>
+00331 <font class="comment"></font>
+00332 <font class="comment"> buffer.fill (tail, size);</font>
+00333 <font class="comment"></font>
+00334 <font class="comment"> // stat code</font>
+00335 <font class="comment"> TTicks after = CTime::getPerformanceTime ();</font>
+00336 <font class="comment"> _FrontedTime += after - before;</font>
+00337 <font class="comment"></font>
+00338 <font class="comment">#if DEBUG_FIFO</font>
+00339 <font class="comment"> display ();</font>
+00340 <font class="comment">#endif*/</font>
+00341 }
+00342
+<a name="l00343"></a><a class="code" href="classNLMISC_1_1CBufFIFO.html#a8">00343</a> <font class="keywordtype">void</font> CBufFIFO::front (uint8 *&amp;buffer, uint32 &amp;size)
+00344 {
+00345 <a class="code" href="namespaceNLMISC.html#a184">TTicks</a> before = CTime::getPerformanceTime ();
+00346
+00347 uint8 *tail = <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a>;
+00348
+00349 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#a12">empty</a> ())
+00350 {
+00351 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"Try to get the front of an empty fifo!"</font>);
+00352 <font class="keywordflow">return</font>;
+00353 }
+00354
+00355 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o11">_Fronted</a>++;
+00356
+00357 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> != NULL &amp;&amp; tail == <a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a>)
+00358 {
+00359 <font class="preprocessor">#if DEBUG_FIFO</font>
+00360 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p front rewind!"</font>, <font class="keyword">this</font>);
+00361 <font class="preprocessor">#endif</font>
+00362 <font class="preprocessor"></font>
+00363 <font class="comment">// need to rewind</font>
+00364 tail = <a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a>;
+00365 }
+00366
+00367 <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> = *(<a class="code" href="classNLMISC_1_1CBufFIFO.html#u0">TFifoSize</a> *)tail;
+00368
+00369 <font class="preprocessor">#if DEBUG_FIFO</font>
+00370 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p front(%d)"</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>);
+00371 <font class="preprocessor">#endif</font>
+00372 <font class="preprocessor"></font>
+00373 tail += <font class="keyword">sizeof</font> (TFifoSize);
+00374
+00375 <font class="comment">// stat code</font>
+00376 <a class="code" href="namespaceNLMISC.html#a184">TTicks</a> after = CTime::getPerformanceTime ();
+00377 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o14">_FrontedTime</a> += after - before;
+00378
+00379 <font class="preprocessor">#if DEBUG_FIFO</font>
+00380 <font class="preprocessor"></font> <a class="code" href="classNLMISC_1_1CBufFIFO.html#a15">display</a> ();
+00381 <font class="preprocessor">#endif</font>
+00382 <font class="preprocessor"></font>
+00383 buffer = tail;
+00384 }
+00385
+00386
+00387
+<a name="l00388"></a><a class="code" href="classNLMISC_1_1CBufFIFO.html#a13">00388</a> <font class="keywordtype">void</font> CBufFIFO::clear ()
+00389 {
+00390 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a> = <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> = <a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a>;
+00391 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> = NULL;
+00392 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o2">_Empty</a> = <font class="keyword">true</font>;
+00393 }
+00394
+<a name="l00395"></a><a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">00395</a> uint32 <a class="code" href="cf__lexical_8cpp.html#a94">CBufFIFO::size</a> ()
+00396 {
+00397 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#a12">empty</a> ())
+00398 {
+00399 <font class="keywordflow">return</font> 0;
+00400 }
+00401 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> == <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a>)
+00402 {
+00403 <font class="comment">// buffer is full</font>
+00404 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> == NULL)
+00405 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBufFIFO.html#o1">_BufferSize</a>;
+00406 <font class="keywordflow">else</font>
+00407 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> - <a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a>;
+00408 }
+00409 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> &gt; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a>)
+00410 {
+00411 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> - <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a>;
+00412 }
+00413 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> &lt; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a>)
+00414 {
+00415 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> != NULL);
+00416 <font class="keywordflow">return</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> - <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a>) + (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> - <a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a>);
+00417 }
+00418 <a class="code" href="debug_8h.html#a12">nlstop</a>;
+00419 <font class="keywordflow">return</font> 0;
+00420 }
+00421
+<a name="l00422"></a><a class="code" href="classNLMISC_1_1CBufFIFO.html#a11">00422</a> <font class="keywordtype">void</font> CBufFIFO::resize (uint32 size)
+00423 {
+00424 <a class="code" href="namespaceNLMISC.html#a184">TTicks</a> before = CTime::getPerformanceTime();
+00425
+00426 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> == 0) <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> = 100;
+00427
+00428 <font class="preprocessor">#if DEBUG_FIFO</font>
+00429 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p resize(%d)"</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>);
+00430 <font class="preprocessor">#endif</font>
+00431 <font class="preprocessor"></font>
+00432 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> &gt; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o8">_BiggestBuffer</a>) <a class="code" href="classNLMISC_1_1CBufFIFO.html#o8">_BiggestBuffer</a> = <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>;
+00433 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> &lt; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o9">_SmallestBuffer</a>) <a class="code" href="classNLMISC_1_1CBufFIFO.html#o9">_SmallestBuffer</a> = <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>;
+00434
+00435 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o12">_Resized</a>++;
+00436
+00437 uint32 UsedSize = <a class="code" href="cf__lexical_8cpp.html#a94">CBufFIFO::size</a>();
+00438
+00439 <font class="comment">// creer un nouveau tableau et copie l ancien dans le nouveau.</font>
+00440 <font class="keywordflow">if</font> (size &lt; _BufferSize &amp;&amp; UsedSize &gt; <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>)
+00441 {
+00442 <font class="comment">// probleme, on a pas assez de place pour caser les datas =&gt; on fait pas</font>
+00443 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"Can't resize the FIFO because there's not enough room in the new wanted buffer (%d bytes needed at least)"</font>, UsedSize);
+00444 <font class="keywordflow">return</font>;
+00445 }
+00446
+00447 uint8 *NewBuffer = <font class="keyword">new</font> uint8[<a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>];
+00448 <font class="keywordflow">if</font> (NewBuffer == NULL)
+00449 {
+00450 <a class="code" href="debug_8h.html#a3">nlerror</a>(<font class="stringliteral">"Not enough memory to resize the FIFO to %u bytes"</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>);
+00451 }
+00452 <font class="preprocessor">#ifdef NL_DEBUG</font>
+00453 <font class="preprocessor"></font> <font class="comment">// clear the message to be sure user doesn't use it anymore</font>
+00454 memset (NewBuffer, <font class="charliteral">'-'</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>);
+00455 <font class="preprocessor">#endif</font>
+00456 <font class="preprocessor"></font>
+00457 <font class="preprocessor">#if DEBUG_FIFO</font>
+00458 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p new %d bytes"</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>);
+00459 <font class="preprocessor">#endif</font>
+00460 <font class="preprocessor"></font>
+00461 <font class="comment">// copy the old buffer to the new one</font>
+00462 <font class="comment">// if _Tail == _Head =&gt; empty fifo, don't copy anything</font>
+00463 <font class="keywordflow">if</font> (!<a class="code" href="classNLMISC_1_1CBufFIFO.html#a12">empty</a>())
+00464 {
+00465 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a> &lt; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a>)
+00466 {
+00467 CFastMem::memcpy (NewBuffer, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a>, UsedSize);
+00468 }
+00469 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a> &gt;= <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a>)
+00470 {
+00471 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> != NULL);
+00472
+00473 uint size1 = <a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> - <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a>;
+00474 CFastMem::memcpy (NewBuffer, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a>, size1);
+00475 uint size2 = <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> - <a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a>;
+00476 CFastMem::memcpy (NewBuffer + size1, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a>, size2);
+00477
+00478 <a class="code" href="debug_8h.html#a6">nlassert</a> (size1+size2==UsedSize);
+00479 }
+00480 }
+00481
+00482 <font class="comment">// resync the circular pointer</font>
+00483 <font class="comment">// Warning: don't invert these 2 lines position or it ll not work</font>
+00484 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a> = NewBuffer;
+00485 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> = NewBuffer + UsedSize;
+00486 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> = NULL;
+00487
+00488 <font class="comment">// delete old buffer if needed</font>
+00489 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a> != NULL)
+00490 {
+00491 <font class="keyword">delete</font> <a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a>;
+00492 <font class="preprocessor">#if DEBUG_FIFO</font>
+00493 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"delete"</font>, <font class="keyword">this</font>);
+00494 <font class="preprocessor">#endif</font>
+00495 <font class="preprocessor"></font> }
+00496
+00497 <font class="comment">// affect new buffer</font>
+00498 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a> = NewBuffer;
+00499 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o1">_BufferSize</a> = <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>;
+00500
+00501 <a class="code" href="namespaceNLMISC.html#a184">TTicks</a> after = CTime::getPerformanceTime();
+00502
+00503 <a class="code" href="classNLMISC_1_1CBufFIFO.html#o15">_ResizedTime</a> += after - before;
+00504
+00505 <font class="preprocessor">#if DEBUG_FIFO</font>
+00506 <font class="preprocessor"></font> <a class="code" href="classNLMISC_1_1CBufFIFO.html#a15">display</a> ();
+00507 <font class="preprocessor">#endif</font>
+00508 <font class="preprocessor"></font>}
+00509
+<a name="l00510"></a><a class="code" href="classNLMISC_1_1CBufFIFO.html#a16">00510</a> <font class="keywordtype">void</font> CBufFIFO::displayStats ()
+00511 {
+00512 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"%p _BiggestBlock: %d"</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o6">_BiggestBlock</a>);
+00513 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"%p _SmallestBlock: %d"</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o7">_SmallestBlock</a>);
+00514 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"%p _BiggestBuffer: %d"</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o8">_BiggestBuffer</a>);
+00515 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"%p _SmallestBuffer: %d"</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o9">_SmallestBuffer</a>);
+00516 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"%p _Pushed : %d"</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o10">_Pushed</a>);
+00517 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"%p _Fronted: %d"</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o11">_Fronted</a>);
+00518 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"%p _Resized: %d"</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o12">_Resized</a>);
+00519 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"%p _PushedTime: %"</font>NL_I64<font class="stringliteral">"d %f"</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o13">_PushedTime</a>, (<font class="keywordtype">double</font>)(sint64)<a class="code" href="classNLMISC_1_1CBufFIFO.html#o13">_PushedTime</a> / (<font class="keywordtype">double</font>)<a class="code" href="classNLMISC_1_1CBufFIFO.html#o10">_Pushed</a>);
+00520 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"%p _FrontedTime: %"</font>NL_I64<font class="stringliteral">"d %f"</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o14">_FrontedTime</a>, (<font class="keywordtype">double</font>)(sint64)<a class="code" href="classNLMISC_1_1CBufFIFO.html#o14">_FrontedTime</a> / (<font class="keywordtype">double</font>)<a class="code" href="classNLMISC_1_1CBufFIFO.html#o11">_Fronted</a>);
+00521 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"%p _ResizedTime: %"</font>NL_I64<font class="stringliteral">"d %f"</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o15">_ResizedTime</a>, (<font class="keywordtype">double</font>)(sint64)<a class="code" href="classNLMISC_1_1CBufFIFO.html#o15">_ResizedTime</a> / (<font class="keywordtype">double</font>)<a class="code" href="classNLMISC_1_1CBufFIFO.html#o12">_Resized</a>);
+00522 }
+00523
+<a name="l00524"></a><a class="code" href="classNLMISC_1_1CBufFIFO.html#a15">00524</a> <font class="keywordtype">void</font> CBufFIFO::display ()
+00525 {
+00526 <font class="keywordtype">int</font> <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a> = 64;
+00527 <font class="keywordtype">int</font> gran = <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>/30;
+00528
+00529 <font class="keywordtype">char</font> str[1024];
+00530
+00531 <a class="code" href="namespaceNLMISC.html#a211">smprintf</a>(str, 1024, <font class="stringliteral">"%p %p (%5d %5d) %p %p %p "</font>, <font class="keyword">this</font>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o1">_BufferSize</a>, CBufFIFO::size(), <a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a>, <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a>);
+00532
+00533 <font class="keywordtype">int</font> i;
+00534 <font class="keywordflow">for</font> (i = 0; i &lt; (sint32) <a class="code" href="classNLMISC_1_1CBufFIFO.html#o1">_BufferSize</a>; i+= gran)
+00535 {
+00536 uint8 *pos = <a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a> + i;
+00537 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a> &gt;= pos &amp;&amp; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a> &lt; pos + gran)
+00538 {
+00539 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> &gt;= pos &amp;&amp; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> &lt; pos + gran)
+00540 {
+00541 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> != NULL &amp;&amp; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> &gt;= pos &amp;&amp; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> &lt; pos + gran)
+00542 {
+00543 strncat (str, <font class="stringliteral">"*"</font>, 1024);
+00544 }
+00545 <font class="keywordflow">else</font>
+00546 {
+00547 strncat (str, <font class="stringliteral">"@"</font>, 1024);
+00548 }
+00549 }
+00550 <font class="keywordflow">else</font>
+00551 {
+00552 strncat (str, <font class="stringliteral">"T"</font>, 1024);
+00553 }
+00554 }
+00555 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> &gt;= pos &amp;&amp; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> &lt; pos + gran)
+00556 {
+00557 strncat (str, <font class="stringliteral">"H"</font>, 1024);
+00558 }
+00559 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> != NULL &amp;&amp; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> &gt;= pos &amp;&amp; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> &lt; pos + gran)
+00560 {
+00561 strncat (str, <font class="stringliteral">"R"</font>, 1024);
+00562 }
+00563 <font class="keywordflow">else</font>
+00564 {
+00565 <font class="keywordflow">if</font> (strlen(str) &lt; 1023)
+00566 {
+00567 uint32 p = strlen(str);
+00568 <font class="keywordflow">if</font> (isprint(*pos))
+00569 str[p] = *pos;
+00570 <font class="keywordflow">else</font>
+00571 str[p] = <font class="charliteral">'$'</font>;
+00572
+00573 str[p+1] = <font class="charliteral">'\0'</font>;
+00574 }
+00575 }
+00576 }
+00577
+00578 <font class="keywordflow">for</font> (; i &lt; <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>; i+= gran)
+00579 {
+00580 strncat (str, <font class="stringliteral">" "</font>, 1024);
+00581 }
+00582 <font class="preprocessor">#ifdef NL_DEBUG</font>
+00583 <font class="preprocessor"></font> strncat (str, <font class="stringliteral">"\n"</font>, 1024);
+00584 <font class="preprocessor">#else</font>
+00585 <font class="preprocessor"></font> strncat (str, <font class="stringliteral">"\r"</font>, 1024);
+00586 <font class="preprocessor">#endif</font>
+00587 <font class="preprocessor"></font> <a class="code" href="namespaceNLMISC.html#a11">DebugLog</a>-&gt;display (str);
+00588 }
+00589
+<a name="l00590"></a><a class="code" href="classNLMISC_1_1CBufFIFO.html#c0">00590</a> <font class="keywordtype">bool</font> CBufFIFO::canFit (uint32 size)
+00591 {
+00592 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a> == <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a>)
+00593 {
+00594 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#a12">empty</a>())
+00595 {
+00596 <font class="comment">// is the buffer large enough?</font>
+00597 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o1">_BufferSize</a> &gt;= <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>)
+00598 {
+00599 <font class="comment">// reset the pointer</font>
+00600 <font class="preprocessor">#if DEBUG_FIFO</font>
+00601 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p reset tail and head"</font>, <font class="keyword">this</font>);
+00602 <font class="preprocessor">#endif</font>
+00603 <font class="preprocessor"></font> <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> = <a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a> = <a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a>;
+00604 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00605 }
+00606 <font class="keywordflow">else</font>
+00607 {
+00608 <font class="comment">// buffer not big enough</font>
+00609 <font class="preprocessor">#if DEBUG_FIFO</font>
+00610 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p buffer full buffersize&lt;size"</font>, <font class="keyword">this</font>);
+00611 <font class="preprocessor">#endif</font>
+00612 <font class="preprocessor"></font> <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00613 }
+00614 }
+00615 <font class="keywordflow">else</font>
+00616 {
+00617 <font class="comment">// buffer full</font>
+00618 <font class="preprocessor">#if DEBUG_FIFO</font>
+00619 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p buffer full h=t"</font>, <font class="keyword">this</font>);
+00620 <font class="preprocessor">#endif</font>
+00621 <font class="preprocessor"></font> <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00622 }
+00623 }
+00624 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a> &lt; <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a>)
+00625 {
+00626 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a> + <a class="code" href="classNLMISC_1_1CBufFIFO.html#o1">_BufferSize</a> - <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> &gt;= (sint32) <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>)
+00627 {
+00628 <font class="comment">// can fit after _Head</font>
+00629 <font class="preprocessor">#if DEBUG_FIFO</font>
+00630 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p fit after"</font>, <font class="keyword">this</font>);
+00631 <font class="preprocessor">#endif</font>
+00632 <font class="preprocessor"></font> <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00633 }
+00634 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a> - <a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a> &gt;= (sint32) <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>)
+00635 {
+00636 <font class="comment">// can fit at the beginning</font>
+00637 <font class="preprocessor">#if DEBUG_FIFO</font>
+00638 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p fit at beginning"</font>, <font class="keyword">this</font>);
+00639 <font class="preprocessor">#endif</font>
+00640 <font class="preprocessor"></font> <a class="code" href="classNLMISC_1_1CBufFIFO.html#o5">_Rewinder</a> = <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a>;
+00641 <font class="preprocessor">#if DEBUG_FIFO</font>
+00642 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p set the rewinder"</font>, <font class="keyword">this</font>);
+00643 <font class="preprocessor">#endif</font>
+00644 <font class="preprocessor"></font> <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> = <a class="code" href="classNLMISC_1_1CBufFIFO.html#o0">_Buffer</a>;
+00645 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00646 }
+00647 <font class="keywordflow">else</font>
+00648 {
+00649 <font class="comment">// can't fit</font>
+00650 <font class="preprocessor">#if DEBUG_FIFO</font>
+00651 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p no room t&lt;h"</font>, <font class="keyword">this</font>);
+00652 <font class="preprocessor">#endif</font>
+00653 <font class="preprocessor"></font> <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00654 }
+00655 }
+00656 <font class="keywordflow">else</font> <font class="comment">// the last case is : if (_Tail &gt; _Head)</font>
+00657 {
+00658 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBufFIFO.html#o4">_Tail</a> - <a class="code" href="classNLMISC_1_1CBufFIFO.html#o3">_Head</a> &gt;= (sint32) <a class="code" href="classNLMISC_1_1CBufFIFO.html#a14">size</a>)
+00659 {
+00660 <font class="preprocessor">#if DEBUG_FIFO</font>
+00661 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p fit t&gt;h"</font>, <font class="keyword">this</font>);
+00662 <font class="preprocessor">#endif</font>
+00663 <font class="preprocessor"></font> <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00664 }
+00665 <font class="keywordflow">else</font>
+00666 {
+00667 <font class="preprocessor">#if DEBUG_FIFO</font>
+00668 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"%p no room t&gt;h"</font>, <font class="keyword">this</font>);
+00669 <font class="preprocessor">#endif</font>
+00670 <font class="preprocessor"></font> <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00671 }
+00672 }
+00673 <a class="code" href="debug_8h.html#a12">nlstop</a>;
+00674 }
+00675
+00676
+00677 } <font class="comment">// NLMISC</font>
+</pre></div>
+
+<!-- footer -->
+<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
+</TD>
+<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>