lliobuffer.cpp

Go to the documentation of this file.
00001 
00034 #include "linden_common.h"
00035 #include "lliobuffer.h"
00036 
00037 //
00038 // LLIOBuffer
00039 //
00040 LLIOBuffer::LLIOBuffer() :
00041         mBuffer(NULL),
00042         mBufferSize(0L),
00043         mReadHead(NULL),
00044         mWriteHead(NULL)
00045 {
00046 }
00047 
00048 LLIOBuffer::~LLIOBuffer()
00049 {
00050         if(mBuffer)
00051         {
00052                 delete[] mBuffer;
00053         }
00054 }
00055 
00056 U8* LLIOBuffer::data() const
00057 {
00058         return mBuffer;
00059 }
00060 
00061 S64 LLIOBuffer::size() const
00062 {
00063         return mBufferSize;
00064 }
00065 
00066 U8* LLIOBuffer::current() const
00067 {
00068         return mReadHead;
00069 }
00070 
00071 S64 LLIOBuffer::bytesLeft() const
00072 {
00073         return mWriteHead - mReadHead;
00074 }
00075 
00076 void LLIOBuffer::clear()
00077 {
00078         mReadHead = mBuffer;
00079         mWriteHead = mBuffer;
00080 }
00081 
00082 LLIOPipe::EStatus LLIOBuffer::seek(LLIOBuffer::EHead head, S64 delta)
00083 {
00084         LLIOPipe::EStatus status = STATUS_ERROR;
00085         switch(head)
00086         {
00087         case READ:
00088                 if(((delta >= 0) && ((mReadHead + delta) <= mWriteHead))
00089                    || (delta < 0) && ((mReadHead + delta) >= mBuffer))
00090                 {
00091                         mReadHead += delta;
00092                         status = STATUS_OK;
00093                 }
00094                 break;
00095         case WRITE:
00096                 if(((delta >= 0) && ((mWriteHead + delta) < (mBuffer + mBufferSize)))
00097                    || (delta < 0) && ((mWriteHead + delta) > mReadHead))
00098                 {
00099                         mWriteHead += delta;
00100                         status = STATUS_OK;
00101                 }
00102         default:
00103                 break;
00104         }
00105         return status;
00106 }
00107 
00108 // virtual
00109 LLIOPipe::EStatus LLIOBuffer::process_impl(
00110         const LLChannelDescriptors& channels,
00111         buffer_ptr_t& buffer,
00112         bool& eos,
00113         LLSD& context,
00114         LLPumpIO* pump)
00115 {
00116         // no-op (I think)
00117         llwarns << "You are using an LLIOBuffer which is deprecated." << llendl;
00118         return STATUS_OK;
00119 }

Generated on Thu Jul 1 06:08:46 2010 for Second Life Viewer by  doxygen 1.4.7