00001 #ifndef _DESPERADO_CELLRATETHROTTLE_H_ 00002 #define _DESPERADO_CELLRATETHROTTLE_H_ 00003 00004 /* vim: set ts=4 expandtab shiftwidth=4: */ 00005 00006 /****************************************************************************** 00007 00008 Copyright 2006-2007 Digital Aggregates Corp., Arvada CO 80001-0587, USA. 00009 This file is part of the Digital Aggregates Desperado library. 00010 00011 This library is free software; you can redistribute it and/or 00012 modify it under the terms of the GNU Lesser General Public 00013 License as published by the Free Software Foundation; either 00014 version 2.1 of the License, or (at your option) any later version. 00015 00016 As a special exception, if other files instantiate templates or 00017 use macros or inline functions from this file, or you compile 00018 this file and link it with other works to produce a work based on 00019 this file, this file does not by itself cause the resulting work 00020 to be covered by the GNU Lesser General Public License. However 00021 the source code for this file must still be made available in 00022 accordance with the GNU Lesser General Public License. 00023 00024 This exception does not invalidate any other reasons why a work 00025 based on this file might be covered by the GNU Lesser General 00026 Public License. 00027 00028 Alternative commercial licensing terms are available from the copyright 00029 holder. Contact Digital Aggregates Corporation for more information. 00030 00031 This library is distributed in the hope that it will be useful, 00032 but WITHOUT ANY WARRANTY; without even the implied warranty of 00033 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00034 GNU Lesser General Public License for more details. 00035 00036 You should have received a copy of the GNU Lesser General 00037 Public License along with this library; if not, write to the 00038 Free Software Foundation, Inc., 59 Temple Place, Suite 330, 00039 Boston, MA 02111-1307 USA, or http://www.gnu.org/copyleft/lesser.txt. 00040 00041 $Name: $ 00042 00043 $Id: CellRateThrottle.h,v 1.28 2007/01/31 23:23:56 jsloan Exp $ 00044 00045 ******************************************************************************/ 00046 00047 00063 #include "target.h" 00064 #include "CompoundThrottle.h" 00065 #include "Gcra.h" 00066 00067 00105 class CellRateThrottle : public CompoundThrottle { 00106 00107 public: 00108 00120 static ticks_t increment(uint32_t pcr, uint32_t cdvt); 00121 00133 static ticks_t limit(uint32_t pcr, uint32_t cdvt); 00134 00151 static ticks_t increment(uint32_t pcr, uint32_t cdvt, uint32_t scr, uint32_t mbs); 00152 00169 static ticks_t limit(uint32_t pcr, uint32_t cdvt, uint32_t scr, uint32_t mbs); 00170 00175 explicit CellRateThrottle(); 00176 00189 explicit CellRateThrottle(uint32_t pcr, uint32_t cdvt); 00190 00209 explicit CellRateThrottle(uint32_t pcr, uint32_t cdvt, uint32_t scr, uint32_t mbs); 00210 00214 virtual ~CellRateThrottle(); 00215 00231 virtual bool initialize(); 00232 00254 virtual bool initialize( 00255 uint32_t pcr, 00256 uint32_t cdvt 00257 ); 00258 00285 virtual bool initialize( 00286 uint32_t pcr, 00287 uint32_t cdvt, 00288 uint32_t scr, 00289 uint32_t mbs 00290 ); 00291 00313 virtual void show(int level = 0, Output* display = 0, int indent = 0) const; 00314 00315 private: 00316 00317 Gcra peak; 00318 00319 Gcra sustained; 00320 00321 }; 00322 00323 00344 extern "C" int unittestCellRateThrottle( 00345 void* pVM, 00346 unsigned int pcr, 00347 unsigned int cdvt, 00348 unsigned int scr, 00349 unsigned int mbs, 00350 unsigned int iterations 00351 ); 00352 00353 00354 #endif