bufferreader.h

00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Gav Wood                                        *
00003  *   gav@cs.york.ac.uk                                                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Library General Public License as       *
00007  *   published by the Free Software Foundation; either version 2 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  ***************************************************************************/
00010 #ifndef GEDDEIBUFFERREADER_H
00011 #define GEDDEIBUFFERREADER_H
00012 
00013 #ifdef __GEDDEI_BUILD
00014 #include "bufferdata.h"
00015 #include "signaltype.h"
00016 #include "buffer.h"
00017 #else
00018 #include <geddei/bufferdata.h>
00019 #include <geddei/signaltype.h>
00020 #include <geddei/buffer.h>
00021 #endif
00022 
00023 namespace Geddei
00024 {
00025 
00026 class Processor;
00027 
00032 class BufferReader : public ScreenOwner
00033 {
00034  friend class Buffer;
00035  Buffer *theBuffer;
00036  BufferInfo *lastRead;
00037  uint readPos, lastReadSize, theUsed, theToBeSkipped, theAlreadyPlungedHere;
00038 
00042  void skipElementsUNSAFE(const uint elements);
00043 
00047  void clearUNSAFE();
00048 
00049 public:
00050  void openTrapdoor(const Processor *processor);
00051  void closeTrapdoor(const Processor *processor);
00052 
00068  void skipPlunger();
00069  
00076  const int nextPlunger() const;
00077 
00089  const uint elementsReady() const;
00090 
00102  void waitForElements(const uint elements) const;
00103 
00117  const BufferData readElements(const uint elements, bool autoFree = true);
00118 
00141  void skipElements(const uint elements);
00142 
00143  //* Reimplementation from ScreenOwner.
00144 
00155  virtual void haveRead(const BufferData &data);
00156 
00165  virtual void forgetRead(const BufferData &data);
00166 
00170  const SignalType *type() const { return theBuffer->type(); }
00171 
00175  const uint size() const { return theBuffer->size(); }
00176 
00177  void debug();
00178 
00179  BufferReader(Buffer *buffer);
00180  virtual ~BufferReader();
00181 };
00182 
00183 }
00184 
00185 #endif

Generated on Fri Nov 10 21:58:26 2006 for Exscalibar by  doxygen 1.5.1