00001 /* 00002 * Copyright (C) 2009, Edmundo Albuquerque de Souza e Silva. 00003 * 00004 * This file may be distributed under the terms of the Q Public License 00005 * as defined by Trolltech AS of Norway and appearing in the file 00006 * LICENSE.QPL included in the packaging of this file. 00007 * 00008 * THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING 00009 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00010 * PURPOSE. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, 00011 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 00012 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00013 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 00014 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00015 * 00016 */ 00017 00018 /////////////////////////////////////////////////////////////////////////////// 00019 // buffer.h : Include file for buffer manager 00020 // of storageserver 00021 /////////////////////////////////////////////////////////////////////////////// 00022 00023 #ifndef __BUFFER_H_ 00024 #define __BUFFER_H_ 00025 00026 #include <riofreelist.h> 00027 00028 struct StrBuffer 00029 { 00030 private: 00031 StrBuffer* Next; 00032 public: 00033 char* Data; 00034 }; 00035 00036 /******************************************************************************* 00037 * Class that implements the buffer manager 00038 ******************************************************************************/ 00039 00040 class CBufferManager 00041 { 00042 public: 00043 CBufferManager(); 00044 ~CBufferManager(); 00045 00046 /* Initialize Buffer Pool with nBuffer of size BufferSize */ 00047 int Initialize(unsigned int nBuffer, unsigned int BufferSize); 00048 /* Get a free buffer */ 00049 StrBuffer* New(); 00050 /* Return buffer to free list */ 00051 void Free( StrBuffer* buffer); 00052 00053 private: 00054 CRioFreeList m_FreeList; 00055 StrBuffer* m_Buffer; 00056 char* m_Data; 00057 }; 00058 00059 #endif /* __BUFFER_H_ */