<!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>ucommon: ucommon/containers.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.3 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="main.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <h1>ucommon/containers.h</h1><a href="a00181.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.</span> <a name="l00002"></a>00002 <span class="comment">//</span> <a name="l00003"></a>00003 <span class="comment">// This file is part of GNU uCommon C++.</span> <a name="l00004"></a>00004 <span class="comment">//</span> <a name="l00005"></a>00005 <span class="comment">// GNU uCommon C++ is free software: you can redistribute it and/or modify</span> <a name="l00006"></a>00006 <span class="comment">// it under the terms of the GNU Lesser General Public License as published</span> <a name="l00007"></a>00007 <span class="comment">// by the Free Software Foundation, either version 3 of the License, or</span> <a name="l00008"></a>00008 <span class="comment">// (at your option) any later version.</span> <a name="l00009"></a>00009 <span class="comment">//</span> <a name="l00010"></a>00010 <span class="comment">// GNU uCommon C++ is distributed in the hope that it will be useful,</span> <a name="l00011"></a>00011 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00012"></a>00012 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <a name="l00013"></a>00013 <span class="comment">// GNU Lesser General Public License for more details.</span> <a name="l00014"></a>00014 <span class="comment">//</span> <a name="l00015"></a>00015 <span class="comment">// You should have received a copy of the GNU Lesser General Public License</span> <a name="l00016"></a>00016 <span class="comment">// along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.</span> <a name="l00017"></a>00017 <a name="l00029"></a>00029 <span class="preprocessor">#ifndef _UCOMMON_CONTAINERS_H_</span> <a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#define _UCOMMON_CONTAINERS_H_</span> <a name="l00031"></a>00031 <span class="preprocessor"></span> <a name="l00032"></a>00032 <span class="preprocessor">#ifndef _UCOMMON_CONFIG_H_</span> <a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="a00194.html" title="Various miscellaneous platform specific headers and defines.">ucommon/platform.h</a>></span> <a name="l00034"></a>00034 <span class="preprocessor">#endif</span> <a name="l00035"></a>00035 <span class="preprocessor"></span> <a name="l00036"></a>00036 <span class="preprocessor">#ifndef _UCOMMON_PROTOCOLS_H_</span> <a name="l00037"></a>00037 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="a00195.html" title="Abstract interfaces and support.">ucommon/protocols.h</a>></span> <a name="l00038"></a>00038 <span class="preprocessor">#endif</span> <a name="l00039"></a>00039 <span class="preprocessor"></span> <a name="l00040"></a>00040 <span class="preprocessor">#ifndef _UCOMMON_LINKED_H_</span> <a name="l00041"></a>00041 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="a00188.html" title="Linked objects, lists, templates, and containers.">ucommon/linked.h</a>></span> <a name="l00042"></a>00042 <span class="preprocessor">#endif</span> <a name="l00043"></a>00043 <span class="preprocessor"></span> <a name="l00044"></a>00044 <span class="preprocessor">#ifndef _UCOMMON_MEMORY_H_</span> <a name="l00045"></a>00045 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="a00190.html" title="Private heaps, pools, and associations.">ucommon/memory.h</a>></span> <a name="l00046"></a>00046 <span class="preprocessor">#endif</span> <a name="l00047"></a>00047 <span class="preprocessor"></span> <a name="l00048"></a>00048 <span class="preprocessor">#ifndef _UCOMMON_THREAD_H_</span> <a name="l00049"></a>00049 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="a00202.html" title="Thread classes and sychronization objects.">ucommon/thread.h</a>></span> <a name="l00050"></a>00050 <span class="preprocessor">#endif</span> <a name="l00051"></a>00051 <span class="preprocessor"></span> <a name="l00052"></a>00052 NAMESPACE_UCOMMON <a name="l00053"></a>00053 <a name="l00060"></a><a class="code" href="a00065.html">00060</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00065.html" title="Linked allocator helper for linked_allocator template.">LinkedAllocator</a> : <span class="keyword">private</span> <a class="code" href="a00036.html" title="The conditional is a common base for other thread synchronizing classes.">Conditional</a> <a name="l00061"></a>00061 { <a name="l00062"></a>00062 <span class="keyword">protected</span>: <a name="l00063"></a>00063 <a class="code" href="a00067.html" title="Common base class for all objects that can be formed into a linked list.">LinkedObject</a> *freelist; <a name="l00064"></a>00064 <a name="l00065"></a>00065 <a class="code" href="a00065.html" title="Linked allocator helper for linked_allocator template.">LinkedAllocator</a>(); <a name="l00066"></a>00066 <a name="l00067"></a>00067 <a class="code" href="a00067.html" title="Common base class for all objects that can be formed into a linked list.">LinkedObject</a> *<span class="keyword">get</span>(void); <a name="l00068"></a>00068 <a name="l00069"></a>00069 <a class="code" href="a00067.html" title="Common base class for all objects that can be formed into a linked list.">LinkedObject</a> *<span class="keyword">get</span>(<a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout); <a name="l00070"></a>00070 <a name="l00071"></a>00071 <span class="keywordtype">void</span> <a class="code" href="a00208.html#a8df8e4b667d68be02961ff0d4cd84224" title="Convenience function to unlock shared object through it&#39;s protocol.">release</a>(<a class="code" href="a00067.html" title="Common base class for all objects that can be formed into a linked list.">LinkedObject</a> *node); <a name="l00072"></a>00072 <a name="l00073"></a>00073 <span class="keyword">public</span>: <a name="l00078"></a>00078 operator bool(); <a name="l00079"></a>00079 <a name="l00084"></a>00084 <span class="keywordtype">bool</span> operator!(); <a name="l00085"></a>00085 }; <a name="l00086"></a>00086 <a name="l00096"></a><a class="code" href="a00026.html">00096</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00026.html" title="A thread-safe buffer for serializing and streaming class data.">Buffer</a> : <span class="keyword">protected</span> <a class="code" href="a00036.html" title="The conditional is a common base for other thread synchronizing classes.">Conditional</a> <a name="l00097"></a>00097 { <a name="l00098"></a>00098 <span class="keyword">private</span>: <a name="l00099"></a>00099 <span class="keywordtype">size_t</span> size, objsize; <a name="l00100"></a>00100 caddr_t buf, head, tail; <a name="l00101"></a>00101 <span class="keywordtype">unsigned</span> count, limit; <a name="l00102"></a>00102 <a name="l00103"></a>00103 <span class="keyword">public</span>: <a name="l00109"></a>00109 <a class="code" href="a00026.html" title="A thread-safe buffer for serializing and streaming class data.">Buffer</a>(<span class="keywordtype">size_t</span> size, <span class="keywordtype">size_t</span> count); <a name="l00110"></a>00110 <a name="l00114"></a>00114 <span class="keyword">virtual</span> ~<a class="code" href="a00026.html" title="A thread-safe buffer for serializing and streaming class data.">Buffer</a>(); <a name="l00115"></a>00115 <a name="l00120"></a>00120 <span class="keywordtype">unsigned</span> getSize(<span class="keywordtype">void</span>); <a name="l00121"></a>00121 <a name="l00126"></a>00126 <span class="keywordtype">unsigned</span> getCount(<span class="keywordtype">void</span>); <a name="l00127"></a>00127 <a name="l00133"></a>00133 <span class="keywordtype">void</span> *<span class="keyword">get</span>(<a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout); <a name="l00134"></a>00134 <a name="l00140"></a>00140 <span class="keywordtype">void</span> *<span class="keyword">get</span>(void); <a name="l00141"></a>00141 <a name="l00147"></a>00147 <span class="keywordtype">void</span> put(<span class="keywordtype">void</span> *data); <a name="l00148"></a>00148 <a name="l00155"></a>00155 <span class="keywordtype">bool</span> put(<span class="keywordtype">void</span> *data, <a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout); <a name="l00156"></a>00156 <a name="l00163"></a>00163 <span class="keywordtype">void</span> <a class="code" href="a00208.html#a8df8e4b667d68be02961ff0d4cd84224" title="Convenience function to unlock shared object through it&#39;s protocol.">release</a>(<span class="keywordtype">void</span>); <a name="l00164"></a>00164 <a name="l00170"></a>00170 <span class="keywordtype">void</span> <a class="code" href="a00208.html#aa948d5926268ce79c22778bd81cc6ed9" title="Convenience function to access object copy.">copy</a>(<span class="keywordtype">void</span> *data); <a name="l00171"></a>00171 <a name="l00178"></a>00178 <span class="keywordtype">bool</span> <a class="code" href="a00208.html#aa948d5926268ce79c22778bd81cc6ed9" title="Convenience function to access object copy.">copy</a>(<span class="keywordtype">void</span> *data, <a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout); <a name="l00179"></a>00179 <a name="l00184"></a>00184 operator bool(); <a name="l00185"></a>00185 <a name="l00190"></a>00190 <span class="keywordtype">bool</span> operator!(); <a name="l00191"></a>00191 }; <a name="l00192"></a>00192 <a name="l00203"></a><a class="code" href="a00111.html">00203</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a> : <span class="keyword">protected</span> <a class="code" href="a00100.html" title="An index container for maintaining an ordered list of objects.">OrderedIndex</a>, <span class="keyword">protected</span> <a class="code" href="a00036.html" title="The conditional is a common base for other thread synchronizing classes.">Conditional</a> <a name="l00204"></a>00204 { <a name="l00205"></a>00205 <span class="keyword">private</span>: <a name="l00206"></a>00206 <a class="code" href="a00081.html" title="A managed private heap for small allocations.">mempager</a> *<a class="code" href="a00103.html" title="Mempager managed type factory for pager pool objects.">pager</a>; <a name="l00207"></a>00207 <a class="code" href="a00067.html" title="Common base class for all objects that can be formed into a linked list.">LinkedObject</a> *freelist; <a name="l00208"></a>00208 <span class="keywordtype">size_t</span> used; <a name="l00209"></a>00209 <a name="l00210"></a>00210 <span class="keyword">class </span>__LOCAL member : <span class="keyword">public</span> <a class="code" href="a00101.html" title="A linked object base class for ordered objects.">OrderedObject</a> <a name="l00211"></a>00211 { <a name="l00212"></a>00212 <span class="keyword">public</span>: <a name="l00213"></a>00213 member(<a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a> *q, <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *obj); <a name="l00214"></a>00214 <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *object; <a name="l00215"></a>00215 }; <a name="l00216"></a>00216 <a name="l00217"></a>00217 <span class="keyword">friend</span> <span class="keyword">class </span>member; <a name="l00218"></a>00218 <a name="l00219"></a>00219 <span class="keyword">protected</span>: <a name="l00220"></a>00220 <span class="keywordtype">size_t</span> limit; <a name="l00221"></a>00221 <a name="l00222"></a>00222 <span class="keyword">public</span>: <a name="l00230"></a>00230 <a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a>(<a class="code" href="a00081.html" title="A managed private heap for small allocations.">mempager</a> *<a class="code" href="a00103.html" title="Mempager managed type factory for pager pool objects.">pager</a> = NULL, <span class="keywordtype">size_t</span> number = 0); <a name="l00231"></a>00231 <a name="l00235"></a>00235 ~<a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a>(); <a name="l00236"></a>00236 <a name="l00244"></a>00244 <span class="keywordtype">bool</span> <span class="keyword">remove</span>(<a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *object); <a name="l00245"></a>00245 <a name="l00254"></a>00254 <span class="keywordtype">bool</span> post(<a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *<span class="keywordtype">object</span>, <a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0); <a name="l00255"></a>00255 <a name="l00263"></a>00263 <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *fifo(<a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0); <a name="l00264"></a>00264 <a name="l00272"></a>00272 <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *lifo(<a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0); <a name="l00273"></a>00273 <a name="l00278"></a>00278 <span class="keywordtype">size_t</span> getCount(<span class="keywordtype">void</span>); <a name="l00279"></a>00279 <a name="l00286"></a><a class="code" href="a00111.html#a1222518118b41457b50f090990ff2057">00286</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <span class="keyword">remove</span>(<a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a>& <a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a>, <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *object) <a name="l00287"></a>00287 {<span class="keywordflow">return</span> <a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a>.remove(<span class="keywordtype">object</span>);}; <a name="l00288"></a>00288 <a name="l00296"></a><a class="code" href="a00111.html#af1bf9311e4945c16b8981b25b189bdcb">00296</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> post(<a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a>& <a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a>, <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *<span class="keywordtype">object</span>, <a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0) <a name="l00297"></a>00297 {<span class="keywordflow">return</span> queue.<a class="code" href="a00111.html#a6359cffea4ecafa1526cac8e6f1d879a" title="Post an object into the queue by it&#39;s pointer.">post</a>(<span class="keywordtype">object</span>, timeout);}; <a name="l00298"></a>00298 <a name="l00305"></a><a class="code" href="a00111.html#ad2daa5c296bc88c7a8321aadcdb62f5e">00305</a> <span class="keyword">static</span> <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *fifo(<a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a>& <a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a>, <a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0) <a name="l00306"></a>00306 {<span class="keywordflow">return</span> queue.<a class="code" href="a00111.html#ad8d297d75dec8eeda289f78c774e8a5e" title="Get and remove last object posted to the queue.">fifo</a>(timeout);}; <a name="l00307"></a>00307 <a name="l00314"></a><a class="code" href="a00111.html#aa7b6f39d5001c6c6a14ef1ad84a2c23f">00314</a> <span class="keyword">static</span> <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *lifo(<a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a>& <a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a>, <a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0) <a name="l00315"></a>00315 {<span class="keywordflow">return</span> queue.<a class="code" href="a00111.html#af54770fb4034c5b528604ee7b2f0240d" title="Get and remove first object posted to the queue.">lifo</a>(timeout);}; <a name="l00316"></a>00316 <a name="l00322"></a><a class="code" href="a00111.html#a4b00eea4be774eec4a098202dacb0eff">00322</a> <span class="keyword">static</span> <span class="keywordtype">size_t</span> <a class="code" href="a00100.html#ac7083859b39c78603045b704a52a839d" title="Count of objects this list manages.">count</a>(<a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a>& <a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a>) <a name="l00323"></a>00323 {<span class="keywordflow">return</span> queue.<a class="code" href="a00111.html#a19d2e1ccc642b93701e325cb200acd87" title="Get number of object points currently in the queue.">getCount</a>();}; <a name="l00324"></a>00324 }; <a name="l00325"></a>00325 <a name="l00334"></a><a class="code" href="a00145.html">00334</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a> : <span class="keyword">protected</span> <a class="code" href="a00036.html" title="The conditional is a common base for other thread synchronizing classes.">Conditional</a> <a name="l00335"></a>00335 { <a name="l00336"></a>00336 <span class="keyword">private</span>: <a name="l00337"></a>00337 <a class="code" href="a00067.html" title="Common base class for all objects that can be formed into a linked list.">LinkedObject</a> *freelist, *usedlist; <a name="l00338"></a>00338 <a class="code" href="a00081.html" title="A managed private heap for small allocations.">mempager</a> *<a class="code" href="a00103.html" title="Mempager managed type factory for pager pool objects.">pager</a>; <a name="l00339"></a>00339 <span class="keywordtype">size_t</span> used; <a name="l00340"></a>00340 <a name="l00341"></a>00341 <span class="keyword">class </span>__LOCAL member : <span class="keyword">public</span> <a class="code" href="a00067.html" title="Common base class for all objects that can be formed into a linked list.">LinkedObject</a> <a name="l00342"></a>00342 { <a name="l00343"></a>00343 <span class="keyword">public</span>: <a name="l00344"></a>00344 member(<a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a> *s, <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *obj); <a name="l00345"></a>00345 <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *object; <a name="l00346"></a>00346 }; <a name="l00347"></a>00347 <a name="l00348"></a>00348 <span class="keyword">friend</span> <span class="keyword">class </span>member; <a name="l00349"></a>00349 <a name="l00350"></a>00350 <span class="keyword">protected</span>: <a name="l00351"></a>00351 <span class="keywordtype">size_t</span> limit; <a name="l00352"></a>00352 <a name="l00353"></a>00353 <span class="keyword">public</span>: <a name="l00360"></a>00360 <a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a>(<a class="code" href="a00081.html" title="A managed private heap for small allocations.">mempager</a> *<a class="code" href="a00103.html" title="Mempager managed type factory for pager pool objects.">pager</a> = NULL, <span class="keywordtype">size_t</span> number = 0); <a name="l00361"></a>00361 <a name="l00365"></a>00365 ~<a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a>(); <a name="l00366"></a>00366 <a name="l00374"></a>00374 <span class="keywordtype">bool</span> <span class="keyword">remove</span>(<a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *object); <a name="l00375"></a>00375 <a name="l00384"></a>00384 <span class="keywordtype">bool</span> <a class="code" href="a00208.html#a36870182251dc08e9a3eac56452d6218" title="Convenience function to push an object onto a stack.">push</a>(<a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *<span class="keywordtype">object</span>, <a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0); <a name="l00385"></a>00385 <a name="l00393"></a>00393 <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *<a class="code" href="a00208.html#a4aa076e73039e3c66ad07f7ca1827c8e" title="Convenience function to pull an object from a stack.">pull</a>(<a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0); <a name="l00394"></a>00394 <a name="l00399"></a>00399 <span class="keywordtype">size_t</span> getCount(<span class="keywordtype">void</span>); <a name="l00400"></a>00400 <a name="l00407"></a><a class="code" href="a00145.html#aa414c837092039e77fc90659e4c1d158">00407</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <span class="keyword">remove</span>(<a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a>& <a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a>, <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *object) <a name="l00408"></a>00408 {<span class="keywordflow">return</span> <a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a>.remove(<span class="keywordtype">object</span>);}; <a name="l00409"></a>00409 <a name="l00417"></a><a class="code" href="a00145.html#abd729c09fef907e8a1ea2f15f7c792f9">00417</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="a00208.html#a36870182251dc08e9a3eac56452d6218" title="Convenience function to push an object onto a stack.">push</a>(<a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a>& <a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a>, <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *<span class="keywordtype">object</span>, <a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0) <a name="l00418"></a>00418 {<span class="keywordflow">return</span> stack.<a class="code" href="a00145.html#a1e87ca85d0b8df573f706bb74cd337ca" title="Push an object into the stack by it&#39;s pointer.">push</a>(<span class="keywordtype">object</span>, timeout);}; <a name="l00419"></a>00419 <a name="l00426"></a><a class="code" href="a00145.html#a2a08af19a7ab4547833201c08abad022">00426</a> <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *<a class="code" href="a00208.html#a4aa076e73039e3c66ad07f7ca1827c8e" title="Convenience function to pull an object from a stack.">pull</a>(<a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a>& <a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a>, <a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0) <a name="l00427"></a>00427 {<span class="keywordflow">return</span> stack.<a class="code" href="a00145.html#ace7b1d47a03ad947eb592033ae94aa1a" title="Get and remove last object pushed on the stack.">pull</a>(timeout);}; <a name="l00428"></a>00428 <a name="l00434"></a><a class="code" href="a00145.html#afd53bb5e4007d64e64900357b0039e16">00434</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">size_t</span> count(<a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a>& <a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a>) <a name="l00435"></a>00435 {<span class="keywordflow">return</span> stack.<a class="code" href="a00145.html#a4d6ffeb1225b0aa55bfd02ef58410623" title="Get number of object points currently in the stack.">getCount</a>();}; <a name="l00436"></a>00436 }; <a name="l00437"></a>00437 <a name="l00445"></a>00445 <span class="keyword">template</span> <<span class="keyword">class</span> T> <a name="l00446"></a><a class="code" href="a00061.html">00446</a> <span class="keyword">class </span><a class="code" href="a00061.html" title="Linked allocator template to gather linked objects.">linked_allocator</a> : <span class="keyword">public</span> <a class="code" href="a00065.html" title="Linked allocator helper for linked_allocator template.">LinkedAllocator</a> <a name="l00447"></a>00447 { <a name="l00448"></a>00448 <span class="keyword">private</span>: <a name="l00449"></a>00449 T* array; <a name="l00450"></a>00450 <a name="l00451"></a>00451 <span class="keyword">public</span>: <a name="l00452"></a>00452 <span class="keyword">inline</span> <a class="code" href="a00061.html" title="Linked allocator template to gather linked objects.">linked_allocator</a>(<span class="keywordtype">size_t</span> size) : <a class="code" href="a00065.html" title="Linked allocator helper for linked_allocator template.">LinkedAllocator</a>() { <a name="l00453"></a>00453 array = <span class="keyword">new</span> T[size]; <a name="l00454"></a>00454 <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> i = 0; i < size; ++i) <a name="l00455"></a>00455 array[i].enlist(&freelist); <a name="l00456"></a>00456 } <a name="l00457"></a>00457 <a name="l00458"></a>00458 ~<a class="code" href="a00061.html" title="Linked allocator template to gather linked objects.">linked_allocator</a>() <a name="l00459"></a>00459 {<span class="keyword">delete</span>[] array;}; <a name="l00460"></a>00460 <a name="l00461"></a>00461 <span class="keyword">inline</span> T *<span class="keyword">get</span>(void) <a name="l00462"></a>00462 {<span class="keywordflow">return</span> <span class="keyword">static_cast<</span>T *<span class="keyword">></span>(LinkedAllocator::get());}; <a name="l00463"></a>00463 <a name="l00464"></a>00464 <span class="keyword">inline</span> T *<span class="keyword">get</span>(<a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout) <a name="l00465"></a>00465 {<span class="keywordflow">return</span> <span class="keyword">static_cast<</span>T *<span class="keyword">></span>(LinkedAllocator::get(timeout));}; <a name="l00466"></a>00466 <a name="l00467"></a>00467 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a00208.html#a8df8e4b667d68be02961ff0d4cd84224" title="Convenience function to unlock shared object through it&#39;s protocol.">release</a>(T *node) <a name="l00468"></a>00468 {<a class="code" href="a00208.html#a8df8e4b667d68be02961ff0d4cd84224" title="Convenience function to unlock shared object through it&#39;s protocol.">LinkedAllocator::release</a>(node);}; <a name="l00469"></a>00469 }; <a name="l00470"></a>00470 <a name="l00482"></a>00482 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00483"></a><a class="code" href="a00027.html">00483</a> <span class="keyword">class </span><a class="code" href="a00027.html" title="A templated typed class for buffering of objects.">bufferof</a> : <span class="keyword">public</span> <a class="code" href="a00026.html" title="A thread-safe buffer for serializing and streaming class data.">Buffer</a> <a name="l00484"></a>00484 { <a name="l00485"></a>00485 <span class="keyword">public</span>: <a name="l00490"></a><a class="code" href="a00027.html#aa1c8503ffe9c8e95a41123f2d98d48a8">00490</a> <span class="keyword">inline</span> <a class="code" href="a00027.html" title="A templated typed class for buffering of objects.">bufferof</a>(<span class="keywordtype">unsigned</span> count) : <a name="l00491"></a>00491 <a class="code" href="a00026.html" title="A thread-safe buffer for serializing and streaming class data.">Buffer</a>(sizeof(T), count) {}; <a name="l00492"></a>00492 <a name="l00498"></a><a class="code" href="a00027.html#aaf36f574f17e0a40278482306f5e6318">00498</a> <span class="keyword">inline</span> T *<span class="keyword">get</span>(void) <a name="l00499"></a>00499 {<span class="keywordflow">return</span> <span class="keyword">static_cast<</span>T*<span class="keyword">></span>(<span class="keyword">get</span>());}; <a name="l00500"></a>00500 <a name="l00506"></a><a class="code" href="a00027.html#a8ade0d88ead431617345d7b40d574dda">00506</a> <span class="keyword">inline</span> T *<span class="keyword">get</span>(<a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout) <a name="l00507"></a>00507 {<span class="keywordflow">return</span> <span class="keyword">static_cast<</span>T*<span class="keyword">></span>(<span class="keyword">get</span>(timeout));}; <a name="l00508"></a>00508 <a name="l00514"></a><a class="code" href="a00027.html#a4d97ec716dce443b733c028421140026">00514</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> put(T *<span class="keywordtype">object</span>) <a name="l00515"></a>00515 {<a class="code" href="a00027.html#a4d97ec716dce443b733c028421140026" title="Put (copy) a typed object into the buffer.">put</a>(<span class="keywordtype">object</span>);}; <a name="l00516"></a>00516 <a name="l00523"></a><a class="code" href="a00027.html#af8da1b16933b8ad01b9d6facf09b14cd">00523</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> put(T *<span class="keywordtype">object</span>, <a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout) <a name="l00524"></a>00524 {<span class="keywordflow">return</span> <a class="code" href="a00027.html#af8da1b16933b8ad01b9d6facf09b14cd" title="Put (copy) an object into the buffer.">put</a>(<span class="keywordtype">object</span>, timeout);}; <a name="l00525"></a>00525 <a name="l00531"></a><a class="code" href="a00027.html#a8c68eafb8dce1d89f79c2c3d4cb59104">00531</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a00208.html#aa948d5926268ce79c22778bd81cc6ed9" title="Convenience function to access object copy.">copy</a>(T *<span class="keywordtype">object</span>) <a name="l00532"></a>00532 {<a class="code" href="a00027.html#a8c68eafb8dce1d89f79c2c3d4cb59104" title="Copy the next typed object from the buffer.">copy</a>(<span class="keywordtype">object</span>);}; <a name="l00533"></a>00533 <a name="l00540"></a><a class="code" href="a00027.html#a39b39aaf68c0bea6355cb2fb729a53d1">00540</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <span class="keyword">get</span>(T *object, <a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout) <a name="l00541"></a>00541 {<span class="keywordflow">return</span> <a class="code" href="a00208.html#aa948d5926268ce79c22778bd81cc6ed9" title="Convenience function to access object copy.">copy</a>(<span class="keywordtype">object</span>, timeout);}; <a name="l00542"></a>00542 }; <a name="l00543"></a>00543 <a name="l00551"></a>00551 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00552"></a><a class="code" href="a00146.html">00552</a> <span class="keyword">class </span><a class="code" href="a00146.html" title="A templated typed class for thread-safe stack of object pointers.">stackof</a> : <span class="keyword">public</span> <a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a> <a name="l00553"></a>00553 { <a name="l00554"></a>00554 <span class="keyword">public</span>: <a name="l00560"></a><a class="code" href="a00146.html#aa1477c93dceb380c3f06f4221bb4fda4">00560</a> <span class="keyword">inline</span> <a class="code" href="a00146.html#aa1477c93dceb380c3f06f4221bb4fda4" title="Create templated stack of typed objects.">stackof</a>(<a class="code" href="a00081.html" title="A managed private heap for small allocations.">mempager</a> *memory, <span class="keywordtype">size_t</span> size = 0) : <a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a>(memory, size) {}; <a name="l00561"></a>00561 <a name="l00569"></a><a class="code" href="a00146.html#a82ae4121c7a18c6027cfa1c1251c3b8e">00569</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <span class="keyword">remove</span>(T *object) <a name="l00570"></a>00570 {<span class="keywordflow">return</span> <a class="code" href="a00208.html#affa5eb1d4a61e90fb1fc3c3a65a6d849" title="Convenience function to remove an object from a stack.">stack::remove</a>(<span class="keywordtype">object</span>);}; <a name="l00571"></a>00571 <a name="l00580"></a><a class="code" href="a00146.html#a1727da768416d21f2b51a593ff989daa">00580</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="a00208.html#a36870182251dc08e9a3eac56452d6218" title="Convenience function to push an object onto a stack.">push</a>(T *<span class="keywordtype">object</span>, <a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0) <a name="l00581"></a>00581 {<span class="keywordflow">return</span> <a class="code" href="a00208.html#a36870182251dc08e9a3eac56452d6218" title="Convenience function to push an object onto a stack.">stack::push</a>(<span class="keywordtype">object</span>);}; <a name="l00582"></a>00582 <a name="l00590"></a><a class="code" href="a00146.html#aafc34b34a746a1fd374826fc2e322a09">00590</a> <span class="keyword">inline</span> T *<a class="code" href="a00208.html#a4aa076e73039e3c66ad07f7ca1827c8e" title="Convenience function to pull an object from a stack.">pull</a>(<a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0) <a name="l00591"></a>00591 {<span class="keywordflow">return</span> <span class="keyword">static_cast<</span>T *<span class="keyword">></span>(<a class="code" href="a00208.html#a4aa076e73039e3c66ad07f7ca1827c8e" title="Convenience function to pull an object from a stack.">stack::pull</a>(timeout));}; <a name="l00592"></a>00592 }; <a name="l00593"></a>00593 <a name="l00601"></a>00601 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00602"></a><a class="code" href="a00112.html">00602</a> <span class="keyword">class </span><a class="code" href="a00112.html" title="A templated typed class for thread-safe queue of object pointers.">queueof</a> : <span class="keyword">public</span> <a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a> <a name="l00603"></a>00603 { <a name="l00604"></a>00604 <span class="keyword">public</span>: <a name="l00610"></a><a class="code" href="a00112.html#aafe400fe986aa436b308a9c601af92b3">00610</a> <span class="keyword">inline</span> <a class="code" href="a00112.html#aafe400fe986aa436b308a9c601af92b3" title="Create templated queue of typed objects.">queueof</a>(<a class="code" href="a00081.html" title="A managed private heap for small allocations.">mempager</a> *memory, <span class="keywordtype">size_t</span> size = 0) : <a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a>(memory, size) {}; <a name="l00611"></a>00611 <a name="l00619"></a><a class="code" href="a00112.html#ae9b875527c47f1e1d50d3ead48407683">00619</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <span class="keyword">remove</span>(T *object) <a name="l00620"></a>00620 {<span class="keywordflow">return</span> <a class="code" href="a00208.html#affa5eb1d4a61e90fb1fc3c3a65a6d849" title="Convenience function to remove an object from a stack.">queue::remove</a>(<span class="keywordtype">object</span>);}; <a name="l00621"></a>00621 <a name="l00630"></a><a class="code" href="a00112.html#ae10d582103fc1fc250a9569451dd1f52">00630</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> post(T *<span class="keywordtype">object</span>, <a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0) <a name="l00631"></a>00631 {<span class="keywordflow">return</span> queue::post(<span class="keywordtype">object</span>);}; <a name="l00632"></a>00632 <a name="l00640"></a><a class="code" href="a00112.html#abbfe5e24ec8c358d48f1e1248d802187">00640</a> <span class="keyword">inline</span> T *fifo(<a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0) <a name="l00641"></a>00641 {<span class="keywordflow">return</span> <span class="keyword">static_cast<</span>T *<span class="keyword">></span>(queue::fifo(timeout));}; <a name="l00642"></a>00642 <a name="l00650"></a><a class="code" href="a00112.html#acd97c840f476e942b7a5fe7175c58709">00650</a> <span class="keyword">inline</span> T *lifo(<a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = 0) <a name="l00651"></a>00651 {<span class="keywordflow">return</span> <span class="keyword">static_cast<</span>T *<span class="keyword">></span>(queue::lifo(timeout));}; <a name="l00652"></a>00652 }; <a name="l00653"></a>00653 <a name="l00657"></a><a class="code" href="a00208.html#a50a05c4c8e659d989525b1533cebb1ab">00657</a> <span class="keyword">typedef</span> <a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a> <a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack_t</a>; <a name="l00658"></a>00658 <a name="l00662"></a><a class="code" href="a00208.html#adcc328cd561ebe8d432a39124d4e8b7f">00662</a> <span class="keyword">typedef</span> <a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a> <a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">fifo_t</a>; <a name="l00663"></a>00663 <a name="l00669"></a><a class="code" href="a00208.html#a36870182251dc08e9a3eac56452d6218">00669</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a00208.html#a36870182251dc08e9a3eac56452d6218" title="Convenience function to push an object onto a stack.">push</a>(<a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack_t</a> &<a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a>, <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *<span class="keywordtype">object</span>) <a name="l00670"></a>00670 {stack.<a class="code" href="a00145.html#a1e87ca85d0b8df573f706bb74cd337ca" title="Push an object into the stack by it&#39;s pointer.">push</a>(<span class="keywordtype">object</span>);} <a name="l00671"></a>00671 <a name="l00678"></a><a class="code" href="a00208.html#a4aa076e73039e3c66ad07f7ca1827c8e">00678</a> <span class="keyword">inline</span> <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *<a class="code" href="a00208.html#a4aa076e73039e3c66ad07f7ca1827c8e" title="Convenience function to pull an object from a stack.">pull</a>(<a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack_t</a> &<a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a>, <a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = Timer::inf) <a name="l00679"></a>00679 {<span class="keywordflow">return</span> stack.<a class="code" href="a00145.html#ace7b1d47a03ad947eb592033ae94aa1a" title="Get and remove last object pushed on the stack.">pull</a>(timeout);} <a name="l00680"></a>00680 <a name="l00686"></a><a class="code" href="a00208.html#affa5eb1d4a61e90fb1fc3c3a65a6d849">00686</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <span class="keyword">remove</span>(<a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack_t</a> &<a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a>, <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *object) <a name="l00687"></a>00687 {<a class="code" href="a00145.html" title="Manage a thread-safe stack of objects through reference pointers.">stack</a>.remove(<span class="keywordtype">object</span>);} <a name="l00688"></a>00688 <a name="l00694"></a><a class="code" href="a00208.html#a05a684294580146af54daf254ab68f21">00694</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a00208.html#a36870182251dc08e9a3eac56452d6218" title="Convenience function to push an object onto a stack.">push</a>(<a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">fifo_t</a> &fifo, <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *<span class="keywordtype">object</span>) <a name="l00695"></a>00695 {fifo.<a class="code" href="a00111.html#a6359cffea4ecafa1526cac8e6f1d879a" title="Post an object into the queue by it&#39;s pointer.">post</a>(<span class="keywordtype">object</span>);} <a name="l00696"></a>00696 <a name="l00703"></a><a class="code" href="a00208.html#a4d4e9fae24764d25b21fd09b7ac9ce04">00703</a> <span class="keyword">inline</span> <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *<a class="code" href="a00208.html#a4aa076e73039e3c66ad07f7ca1827c8e" title="Convenience function to pull an object from a stack.">pull</a>(<a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">fifo_t</a> &fifo, <a class="code" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout = Timer::inf) <a name="l00704"></a>00704 {<span class="keywordflow">return</span> fifo.<a class="code" href="a00111.html#ad8d297d75dec8eeda289f78c774e8a5e" title="Get and remove last object posted to the queue.">fifo</a>(timeout);} <a name="l00705"></a>00705 <a name="l00711"></a><a class="code" href="a00208.html#ad56cf7e161bd829f5f9a325dcf3e6846">00711</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <span class="keyword">remove</span>(<a class="code" href="a00111.html" title="Manage a thread-safe queue of objects through reference pointers.">fifo_t</a> &fifo, <a class="code" href="a00095.html" title="A common base class for all managed objects.">ObjectProtocol</a> *object) <a name="l00712"></a>00712 {fifo.remove(<span class="keywordtype">object</span>);} <a name="l00713"></a>00713 <a name="l00714"></a>00714 END_NAMESPACE <a name="l00715"></a>00715 <a name="l00716"></a>00716 <span class="preprocessor">#endif</span> </pre></div></div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Thu Jul 14 16:38:56 2011 for ucommon by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>