00001 /* 00002 * Copyright (C) Sergey P. Derevyago, 2008-2009. 00003 * 00004 * Permission to copy, use, modify, sell and distribute this software is granted 00005 * provided this copyright notice appears in all copies. 00006 * This software is provided "as is" without express or implied warranty, and 00007 * with no claim as to its suitability for any purpose. 00008 * 00009 */ 00010 00015 #ifndef __DERS__CYCL_BUF_HPP__ 00016 #define __DERS__CYCL_BUF_HPP__ 00017 00018 #include <ders/config.hpp> 00019 #include <ders/sh_ptr.hpp> 00020 00021 namespace ders { // ::ders 00022 00026 class cycl_buf { 00027 char* buf; 00028 int sz; 00029 int fst, cnt; 00030 00031 cycl_buf(const cycl_buf&); 00032 cycl_buf& operator=(const cycl_buf&); 00033 00034 public: 00035 cycl_buf(int rsrv); 00036 ~cycl_buf() { operator delete(buf); } 00037 00038 int size() const { return cnt; } 00039 void reserve(int n); 00040 00041 void put(const void* ptr, int n); 00042 void put(const cycl_buf& cb); 00043 void put_front(const void* ptr, int n); 00044 void put_front(const cycl_buf& cb); 00045 00046 void get(void* ptr, int n); 00047 }; 00048 00049 typedef sh_ptr<cycl_buf> sh_cycl_buf; 00050 00057 sh_cycl_buf new_cycl_buf(mem_pool& mp, int rsrv); 00058 00059 } // namespace ::ders 00060 00061 #endif // __DERS__CYCL_BUF_HPP__ 00062