00001 /*-------------------------------------------------------------------- 00002 * 00003 * (C) Copyright Koninklijke Philips Electronics NV 2006. 00004 * All rights reserved. This software is licensed under the terms of 00005 * version 2.1 of the GNU Lesser General Public License as published 00006 * by the Free Software Foundation. For licensing and warranty 00007 * information, see the file COPYING in the main directory. 00008 * 00009 *------------------------------------------------------------------*/ 00010 00011 #ifndef BQUEUE_CC 00012 #define BQUEUE_CC 00013 00014 #include <algorithm> 00015 #include <assert.h> 00016 00017 inline bqueue::bqueue(unsigned int sz, unsigned int tokenSize) : 00018 bqueueT<char>(sz*tokenSize), 00019 tsize(tokenSize), 00020 nsize(sz), 00021 ndata(0) 00022 { } 00023 00024 inline bqueue::~bqueue() 00025 { } 00026 00027 inline unsigned int bqueue::size() const 00028 { 00029 return nsize; 00030 } 00031 00032 inline unsigned int bqueue::data() const 00033 { 00034 return ndata; 00035 } 00036 00037 inline unsigned int bqueue::room() const 00038 { 00039 return size() - data(); 00040 } 00041 00042 inline void bqueue::put(const void* p, unsigned int n) 00043 { 00044 bqueueT<char>::put((char*)p, n*tsize); 00045 ndata += n; 00046 } 00047 00048 inline void bqueue::get(void* p, unsigned int n) 00049 { 00050 bqueueT<char>::get((char*)p, n*tsize); 00051 ndata -= n; 00052 } 00053 00054 inline void bqueue::resize(unsigned int sz) 00055 { 00056 bqueueT<char>::resize(sz*tsize); 00057 nsize = sz; 00058 } 00059 00060 #endif