PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llviewerthrottle.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 90 lines | 45 code | 20 blank | 25 comment | 0 complexity | c0491f2f8a12d6873d802e2ef52b174a MD5 | raw file
 1/** 
 2 * @file llviewerthrottle.h
 3 * @brief LLViewerThrottle class header file
 4 *
 5 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
 6 * Second Life Viewer Source Code
 7 * Copyright (C) 2010, Linden Research, Inc.
 8 * 
 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License only.
13 * 
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 * 
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 * 
23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
24 * $/LicenseInfo$
25 */
26
27#ifndef LL_LLVIEWERTHROTTLE_H
28#define LL_LLVIEWERTHROTTLE_H
29
30#include <vector>
31
32#include "llstring.h"
33#include "llframetimer.h"
34#include "llthrottle.h"
35
36class LLViewerThrottleGroup
37{
38	LLViewerThrottleGroup();
39	LLViewerThrottleGroup(const F32 settings[TC_EOF]);
40
41	LLViewerThrottleGroup operator*(const F32 frac) const;
42	LLViewerThrottleGroup operator+(const LLViewerThrottleGroup &b) const;
43	LLViewerThrottleGroup operator-(const LLViewerThrottleGroup &b) const;
44
45	F32 getTotal()			{ return mThrottleTotal; }
46	void sendToSim() const;
47
48	void dump();
49
50	friend class LLViewerThrottle;
51protected:
52	F32 mThrottles[TC_EOF];
53	F32 mThrottleTotal;
54};
55
56class LLViewerThrottle
57{
58public:
59	LLViewerThrottle();
60
61	void setMaxBandwidth(F32 kbits_per_second, BOOL from_event = FALSE);
62
63	void load();
64	void save() const;
65	void sendToSim() const;
66
67	F32 getMaxBandwidth()const			{ return mMaxBandwidth; }
68	F32 getCurrentBandwidth() const		{ return mCurrentBandwidth; }
69
70	void updateDynamicThrottle();
71	void resetDynamicThrottle();
72
73	LLViewerThrottleGroup getThrottleGroup(const F32 bandwidth_kbps);
74
75	static const std::string sNames[TC_EOF];
76protected:
77	F32 mMaxBandwidth;
78	F32 mCurrentBandwidth;
79
80	LLViewerThrottleGroup mCurrent;
81
82	std::vector<LLViewerThrottleGroup> mPresets;
83	
84	LLFrameTimer mUpdateTimer;
85	F32 mThrottleFrac;
86};
87
88extern LLViewerThrottle gViewerThrottle;
89
90#endif // LL_LLVIEWERTHROTTLE_H