/search.css" rel="stylesheet" type="text/css"/> /search.js">
00001 #ifndef DAQREADOUTFORMAT_BYTEBUFFER_H 00002 #define DAQREADOUTFORMAT_BYTEBUFFER_H 00003 00004 /* 00005 * ByteBuffer.h 00006 * DaqReadoutFormat 00007 * 00008 * Created by Simon Patton on 7/18/10. 00009 * Copyright 2010 DayaBay Collaboration. All rights reserved. 00010 * 00011 */ 00012 00013 namespace DybDaq { 00014 00015 class ByteBuffer { 00016 00017 public: 00018 00022 static const unsigned int BYTES_IN_INT; 00023 00027 ByteBuffer(char* contents, 00028 unsigned int capacity); 00029 00033 virtual ~ByteBuffer(); 00034 00038 const char* grab() const; 00039 00043 void release() const; 00044 00048 const unsigned int capacity() const; 00049 00053 const unsigned int remaining() const; 00054 00058 const bool hasRemaining() const; 00059 00063 const unsigned int limit() const; 00064 00068 const ByteBuffer* limit(unsigned int newLimit) const; 00069 00073 const unsigned int position() const; 00074 00078 const ByteBuffer* position(unsigned int newPosition) const; 00079 00083 const char* cursor() const; 00084 00088 const char readChar(unsigned int index) const; 00089 00093 const unsigned int readUnsignedInt(unsigned int index) const; 00094 00098 char* cursor(); 00099 00107 const unsigned int put(const char* source, 00108 const unsigned int length); 00109 00110 private: 00111 00115 ByteBuffer(ByteBuffer& rhs); 00116 00120 ByteBuffer& operator=(ByteBuffer& rhs); 00121 00125 char* m_buffer; 00126 00130 unsigned int m_capacity; 00131 00135 mutable unsigned int m_limit; 00136 00140 mutable unsigned int m_position; 00141 00145 mutable unsigned int m_count; 00146 }; 00147 00148 } 00149 00150 #endif // DAQREADOUTFORMAT_BYTEBUFFER_H