Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

/home/jeroen/FOX/fox/fox-1.7.33/include/FXPtrQueue.h
00001 /********************************************************************************
00002 *                                                                               *
00003 *                         Q u e u e   O f   P o i n t e r s                     *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2006,2012 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 ********************************************************************************/
00021 #ifndef FXPTRQUEUE_H
00022 #define FXPTRQUEUE_H
00023 
00024 namespace FX {
00025 
00026 
00028 class FXAPI FXPtrQueue {
00029 private:
00030   void**          list;         // List of pointers
00031   volatile FXuint size;         // Size of list
00032   volatile FXuint head;         // Write side
00033   volatile FXuint tail;         // Read side
00034 private:
00035   FXPtrQueue(const FXPtrQueue&);
00036   FXPtrQueue &operator=(const FXPtrQueue&);
00037 public:
00038 
00040   FXPtrQueue(FXuint sz=256);
00041 
00043   FXbool setSize(FXuint sz);
00044 
00046   FXuint getSize() const;
00047 
00049   FXuint getHead() const;
00050 
00052   FXuint getTail() const;
00053 
00055   FXuint getUsed() const;
00056 
00058   FXuint getFree() const;
00059 
00061   FXbool isFull() const;
00062 
00064   FXbool isEmpty() const;
00065 
00067   FXbool peek(void*& ptr);
00068 
00070   FXbool push(void* ptr);
00071 
00073   FXbool pop(void*& ptr);
00074 
00076  ~FXPtrQueue();
00077   };
00078 
00079 
00081 template <class TYPE>
00082 class FXPtrQueueOf : public FXPtrQueue {
00083 public:
00084   FXPtrQueueOf(){}
00085   FXPtrQueueOf(FXuint sz):FXPtrQueue(sz){}
00086   FXbool peek(TYPE*& ptr){ return FXPtrQueue::peek((void*&)ptr); }
00087   FXbool push(TYPE* ptr){ return FXPtrQueue::push((void*)ptr); }
00088   FXbool pop(TYPE*& ptr){ return FXPtrQueue::pop((void*&)ptr); }
00089   };
00090 
00091 }
00092 
00093 #endif

Copyright © 1997-2011 Jeroen van der Zijp