X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=proxy%2Fyaz-bw.cpp;fp=proxy%2Fyaz-bw.cpp;h=fabf0864d9aa2bbfc94ce5bbe35b8c1776d7587d;hb=2c25ce513613784819fcb216c60d1584402e7907;hp=0000000000000000000000000000000000000000;hpb=779c379c70bf479073cc4968f6bf5ad35ffe6eec;p=yazpp-moved-to-github.git diff --git a/proxy/yaz-bw.cpp b/proxy/yaz-bw.cpp new file mode 100644 index 0000000..fabf086 --- /dev/null +++ b/proxy/yaz-bw.cpp @@ -0,0 +1,65 @@ +/* $Id: yaz-bw.cpp,v 1.1 2004-03-29 22:46:51 adam Exp $ + Copyright (c) 1998-2004, Index Data. + +This file is part of the yaz-proxy. + +Zebra is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Zebra is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Zebra; see the file LICENSE.proxy. If not, write to the +Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + */ + +#include +#include +#include + +Yaz_bw::Yaz_bw(int sz) +{ + m_sec = 0; + m_size = sz; + m_bucket = new int[m_size]; + m_ptr = 0; +} + +Yaz_bw::~Yaz_bw() +{ + delete [] m_bucket; +} + +int Yaz_bw::get_total() +{ + add_bytes(0); + int bw = 0; + int i; + for (i = 0; i m_size) + d = m_size; + while (--d >= 0) + { + if (++m_ptr == m_size) + m_ptr = 0; + m_bucket[m_ptr] = 0; + } + m_bucket[m_ptr] += b; + m_sec = now; +} +