3
Copyright (C) 2001 Martin Vogt
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU Library General Public License as published by
7
the Free Software Foundation.
9
For more information look at the file COPYRIGHT in this package
14
#include "frameQueue.h"
17
FrameQueue::FrameQueue(int maxsize) {
19
entries = new Frame*[size];
30
FrameQueue::~FrameQueue() {
33
if (entries[i] != NULL) {
40
int FrameQueue::canRead() {
41
return (fillgrade > 0);
45
int FrameQueue::canWrite() {
46
return (fillgrade < size);
50
int FrameQueue::getFillgrade() {
55
void FrameQueue::enqueue(Frame* frame) {
56
if(canWrite() == false) {
57
cout << "FrameQueue full cannot enqueue"<<endl;
61
entries[writepos]=frame;
63
if (writepos == size) {
69
Frame* FrameQueue::dequeue() {
70
if(canRead() == false) {
71
cout << "FrameQueue empty cannot dequeue"<<endl;
74
Frame* back=entries[readpos];
75
// invalide this frame, we do not longer own it!
76
entries[readpos]=NULL;
79
if (readpos == size) {
85
Frame* FrameQueue::peekqueue(int pos) {
86
if(fillgrade-pos <= 0) {
87
cout << "FrameQueue : cannot peek this positon"<<endl;
90
int getpos=(readpos+pos) % size;
93
Frame* back=entries[getpos];