00001
00014 #ifndef __DATA_QUEUE_H__
00015 #define __DATA_QUEUE_H__
00016
00017 #include <data_holder.h>
00018
00024 template <class ItemType> class DataQueue : protected DataHolder<ItemType> {
00025 public:
00030 DataQueue(unsigned long size) throw (NotEnoughMemoryException)
00031 : DataHolder<ItemType>(size), first(0) {
00032 }
00033
00039 inline ItemType get() {
00040 assert (!isEmpty());
00041
00042 ItemType retVal= pool[first];
00043 first= (first + 1) % getSize();
00044 return retVal;
00045 }
00046
00051 inline bool isEmpty() {
00052 return first == last;
00053 }
00054
00060 inline bool isFull() {
00061 return ((last + 1) % getSize()) == first;
00062 }
00063
00064 private:
00068 unsigned long first;
00069
00070 };
00071
00072 #endif // ! __DATA_QUEUE_H__