Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/stack_8h_source.html
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 13 Aug 2010 16:47:46 +0100
changeset 14 578be2adaf3e
parent 6 43e37759235e
permissions -rw-r--r--
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>TB9.2 Example Applications: examples/PIPS/opencproducerconsumerex/inc/stack.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.2 -->
<h1>examples/PIPS/opencproducerconsumerex/inc/stack.h</h1><a href="stack_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00015"></a>00015 <span class="preprocessor">#ifndef STACK_H</span>
<a name="l00016"></a>00016 <span class="preprocessor"></span><span class="preprocessor">#define STACK_H</span>
<a name="l00017"></a>00017 <span class="preprocessor"></span>
<a name="l00018"></a>00018 <span class="comment">/* INCLUDE FILES */</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;CommanHeader.h&quot;</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="comment">/*</span>
<a name="l00024"></a>00024 <span class="comment">C++ Class that defines Stack</span>
<a name="l00025"></a>00025 <span class="comment">*/</span>
<a name="l00026"></a><a class="code" href="class_stack.html">00026</a> <span class="keyword">class </span><a class="code" href="class_stack.html">Stack</a> {
<a name="l00027"></a>00027 <span class="keyword">enum</span> 
<a name="l00028"></a>00028         {
<a name="l00029"></a>00029         EMaxProduction = 1000
<a name="l00030"></a>00030         };
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="keyword">public</span>:
<a name="l00033"></a>00033 
<a name="l00034"></a>00034         <a class="code" href="class_stack.html">Stack</a>() : iStatckTop(-1) 
<a name="l00035"></a>00035         {
<a name="l00036"></a>00036         }
<a name="l00037"></a><a class="code" href="class_stack.html#a40bd5dff912f0e5290777c4b46d17809">00037</a> 
<a name="l00042"></a>00042         <a class="code" href="class_stack.html#a40bd5dff912f0e5290777c4b46d17809">~Stack</a>()
<a name="l00043"></a>00043         {
<a name="l00044"></a>00044                 <a class="code" href="struct_produced_item.html">ProducedItem</a>* item = NULL; 
<a name="l00045"></a>00045                 <span class="keywordflow">do</span>
<a name="l00046"></a>00046                         {
<a name="l00047"></a>00047                         item = <a class="code" href="class_stack.html#afcc483f12294ea49bcacb6cc528ece5a">Pop</a>();
<a name="l00048"></a>00048                         <span class="keyword">delete</span> item;
<a name="l00049"></a>00049                         } <span class="keywordflow">while</span>(item != NULL);
<a name="l00050"></a>00050         }
<a name="l00051"></a>00051 
<a name="l00060"></a>00060         <span class="keywordtype">void</span> <a class="code" href="class_stack.html#a15effcd021a0a8ef515e543140a70a6e">Push</a>( <a class="code" href="struct_produced_item.html">ProducedItem</a>* aItem ) 
<a name="l00061"></a>00061         {
<a name="l00062"></a>00062                 <span class="comment">//If there is enough space to put item onto stack</span>
<a name="l00063"></a>00063                 <span class="keywordflow">if</span>(iStatckTop &lt; EMaxProduction-1)
<a name="l00064"></a>00064                         {
<a name="l00065"></a>00065                         <a class="code" href="struct_produced_item.html">ProducedItem</a>* item = <span class="keyword">new</span> <a class="code" href="struct_produced_item.html">ProducedItem</a>;
<a name="l00066"></a>00066                         memcpy(item, aItem, <span class="keyword">sizeof</span>(<a class="code" href="struct_produced_item.html">ProducedItem</a>));
<a name="l00067"></a>00067                         iItems[++iStatckTop] = item;
<a name="l00068"></a>00068                         }
<a name="l00069"></a>00069                 <span class="comment">//else Ignore it!</span>
<a name="l00070"></a>00070         }
<a name="l00071"></a>00071 
<a name="l00082"></a>00082         <a class="code" href="struct_produced_item.html">ProducedItem</a>* <a class="code" href="class_stack.html#afcc483f12294ea49bcacb6cc528ece5a">Pop</a>() 
<a name="l00083"></a>00083         {
<a name="l00084"></a>00084                 <span class="keywordflow">if</span>(iStatckTop != -1) 
<a name="l00085"></a>00085                 {
<a name="l00086"></a>00086                         <a class="code" href="struct_produced_item.html">ProducedItem</a>* item = iItems[iStatckTop];
<a name="l00087"></a>00087                         iItems[iStatckTop--] = NULL;
<a name="l00088"></a>00088                         <span class="keywordflow">return</span> item;
<a name="l00089"></a>00089                 }
<a name="l00090"></a>00090                 <span class="keywordflow">return</span> NULL;
<a name="l00091"></a>00091         }
<a name="l00092"></a>00092 
<a name="l00093"></a>00093 <span class="keyword">private</span>:
<a name="l00094"></a>00094         <a class="code" href="struct_produced_item.html">ProducedItem</a>*   iItems[EMaxProduction];
<a name="l00095"></a>00095         <span class="keywordtype">int</span>                             iStatckTop;
<a name="l00096"></a>00096 };
<a name="l00097"></a>00097 
<a name="l00098"></a>00098 <span class="preprocessor">#endif </span><span class="comment">/*STACK_H*/</span>
<a name="l00099"></a>00099 
<a name="l00100"></a>00100 <span class="comment">/*  End of File */</span>
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.2 </small></address>
</body>
</html>