Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

phList.h

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002     Phission : 
00003         Realtime Vision Processing System
00004     
00005     Copyright (C) 2003-2006 Philip D.S. Thoren (pthoren@cs.uml.edu)
00006     University of Massachusetts at Lowell,
00007     Laboratory for Artificial Intelligence and Robotics
00008     
00009     This file is part of Phission.
00010 
00011     Phission is free software; you can redistribute it and/or modify
00012     it under the terms of the GNU Lesser General Public License as published by
00013     the Free Software Foundation; either version 2 of the License, or
00014     (at your option) any later version.
00015 
00016     Phission is distributed in the hope that it will be useful,
00017     but WITHOUT ANY WARRANTY; without even the implied warranty of
00018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019     GNU Lesser General Public License for more details.
00020 
00021     You should have received a copy of the GNU Lesser General Public License
00022     along with Phission; if not, write to the Free Software
00023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024 
00025  ---------------------------------------------------------------------------*/
00026 #ifndef _PHLIST_H
00027 #define _PHLIST_H
00028 
00029 #include <phStdint.h>
00030 #include <phObject.h>
00031 #include <phMutex.h>
00032 
00033 /* ------------------------------------------------------------------------ */
00034 /* The phListNode holds data pointers as they go into and out of the
00035  * phList.
00036  *
00037  * *** Not implemented ***
00038  * When the LiveObject methods are being used, phListNodes are removed
00039  * only after every listening client object has received a copy.
00040  * ***********************
00041  *
00042  * Any type of pointer can go through so long as it's contained within
00043  * a phObject class. The phObject class is used to determine whether
00044  * or not a phListNode's data can be copied out of the phList.
00045  *
00046  * Objects are allowed to be added and removed from the phList at the
00047  * same time so long as there are enough objects to permit it.
00048  * The "head" and "tail" of the list are mutexed so an object can be
00049  * added to the head at the same time as one is being removed from the
00050  * tail.
00051  */
00052 
00053 /* ------------------------------------------------------------------------ */
00075 PHAPI(class) phListNode : public phMutex
00076 {
00077 protected:
00078     phListNode *m_next;
00079     phListNode *m_previous;
00080 
00081 public:
00085     phListNode();
00094     ~phListNode();
00095     
00107     int         setNext     ( phListNode *node );
00119     int         setPrevious ( phListNode *node );
00120 
00126     phListNode *getNext     ( );
00133     phListNode *getPrevious ( );
00134 };
00135 
00136 /* ------------------------------------------------------------------------ */
00150 PHAPI(class) phList : public phMutex
00151 {
00152 protected:
00154     uint32_t m_totalNodes;
00155     
00157     phListNode *m_head;
00159     phListNode *m_tail;
00160 
00161 public:
00166     phList();
00172     ~phList();
00173     
00180     uint32_t length();
00187     uint32_t getTotal();
00197     int isEmpty();
00198     
00204     int empty();
00205     
00221     int insert( phListNode *pobj, uint32_t index = 0 );
00222 
00237     int remove( phListNode *pobj );
00238     
00248     int         push   ( phListNode *pobj );
00255     phListNode *pop    ( );
00256     
00269     int         enqueue( phListNode *node );
00281     phListNode *dequeue( );
00282     
00290     int         unshift( phListNode *node );
00297     phListNode *shift  ( );
00298 
00303     phListNode *removeTail();
00311     phListNode *removeHead();
00312 
00320     const phListNode *getHead();
00329     const phListNode *getTail();
00330 };
00331 
00332 #endif /* _PHLIST_H */




Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:44:02 2007 for phission by  doxygen 1.4.4