ColQueue.h

00001 
00002 //---------------------------------------------------------------------------
00003 //                              Queue
00004 //---------------------------------------------------------------------------
00005 //  Copyright (C):
00006 //---------------------------------------------------------------------------
00007 //CVSId: "@(#)$Id: ColQueue.h,v 1.5 2004/04/29 13:54:20 weller Exp $"
00008 
00009 
00010 #ifndef Queue_H
00011 #define Queue_H
00012 #if defined(__sgi) || defined(_WIN32)
00013 #pragma once
00014 #endif
00015 
00016 //---------------------------------------------------------------------------
00017 //  Includes
00018 //---------------------------------------------------------------------------
00019 
00020 #include <vector>
00021 
00022 #include <OpenSG/OSGConfig.h>
00023 #include <OpenSG/OSGLock.h>
00024 
00025 #include <ColExceptions.h>
00026 
00027 
00028 namespace col {
00029 
00030 //---------------------------------------------------------------------------
00031 //  Forward References
00032 //---------------------------------------------------------------------------
00033 
00034 //---------------------------------------------------------------------------
00035 //   Types
00036 //---------------------------------------------------------------------------
00037 
00038 
00039 //---------------------------------------------------------------------------
00040 //  The Class
00041 //---------------------------------------------------------------------------
00042 
00043 template <typename T>
00044 class Queue
00045 {
00046 
00047 
00048 /***************************************************************************/
00049 public:
00050 
00051 //---------------------------------------------------------------------------
00052 //  Public Instance methods
00053 //---------------------------------------------------------------------------
00054 
00055 /*------------------ constructors & destructors ---------------------------*/
00056 
00057     Queue();
00058     virtual ~Queue() throw();
00059 
00060 /*-------------------------- access --------------------------------*/
00061 
00062     void    add( const T &element );
00063     T*      remove();
00064     void    swap();
00065     int     back_size() const;
00066     int     front_size() const;
00067 
00068 //---------------------------------------------------------------------------
00069 //  Public Class methods
00070 //---------------------------------------------------------------------------
00071 
00072 
00073 
00074 
00075 /***************************************************************************/
00076 protected:
00077 
00078 //---------------------------------------------------------------------------
00079 //  Protected Instance methods
00080 //---------------------------------------------------------------------------
00081 
00082     void    init();
00083 
00084 //---------------------------------------------------------------------------
00085 //  Instance variables
00086 //---------------------------------------------------------------------------
00087 
00088     OSG::Lock        *m_write_lock;     // for preventing simul. writing
00089     std::vector<T>  m_elem[2];          // the elements
00090     std::vector<T>   *m_front, *m_back; // pointers to elem[i]
00091     unsigned int     m_back_top;            // next valid element in back queue
00092     unsigned int     m_front_size, m_back_size; // # valid elements
00093 
00094 //---------------------------------------------------------------------------
00095 //  Class variables
00096 //---------------------------------------------------------------------------
00097 
00098     static int M_Num_queue;     // queue counter
00099 
00100 
00101 /***************************************************************************/
00102 private:
00103 
00104 //---------------------------------------------------------------------------
00105 //  Private Instance methods
00106 //---------------------------------------------------------------------------
00107 
00108     // prohibit copy constructor (move to 'public' if you need one)
00109     Queue( const Queue &source );
00110 
00111     // prohibit assignment
00112     Queue& operator = ( const Queue &source );
00113 
00114 
00115 //---------------------------------------------------------------------------
00116 //  Private Class methods
00117 //---------------------------------------------------------------------------
00118 
00119 
00120 };
00121 
00122 
00123 } // namespace col
00124 
00125 #include <ColQueue.hpp>
00126 
00127 
00128 #endif /* Queue_H */
00129 

Generated on Tue Oct 16 18:12:21 2007 for CollDet by  doxygen 1.5.2