llviewerthrottle.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**
  2. * @file llviewerthrottle.h
  3. * @brief LLViewerThrottle class header file
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLVIEWERTHROTTLE_H
  33. #define LL_LLVIEWERTHROTTLE_H
  34. #include <vector>
  35. #include "llframetimer.h"
  36. #include "llstring.h"
  37. #include "llthrottle.h"
  38. class LLViewerThrottleGroup
  39. {
  40. protected:
  41. LOG_CLASS(LLViewerThrottleGroup);
  42. public:
  43. LLViewerThrottleGroup();
  44. LLViewerThrottleGroup(const U32 settings[TC_EOF]);
  45. LLViewerThrottleGroup operator*(F32 frac) const;
  46. LLViewerThrottleGroup operator+(const LLViewerThrottleGroup& b) const;
  47. LLViewerThrottleGroup operator-(const LLViewerThrottleGroup& b) const;
  48. LL_INLINE U32 getTotal() { return mThrottleTotal; }
  49. void sendToSim() const;
  50. void dump();
  51. protected:
  52. U32 mThrottles[TC_EOF];
  53. U32 mThrottleTotal;
  54. };
  55. class LLViewerThrottle
  56. {
  57. protected:
  58. LOG_CLASS(LLViewerThrottle);
  59. public:
  60. LLViewerThrottle();
  61. void setMaxBandwidth(U32 kbps, bool from_event = false);
  62. void load();
  63. void save() const;
  64. void sendToSim() const;
  65. LL_INLINE U32 getMaxBandwidth() const { return mMaxBandwidth; }
  66. LL_INLINE U32 getCurrentBandwidth() const { return mCurrentBandwidth; }
  67. void updateDynamicThrottle();
  68. void resetDynamicThrottle();
  69. LLViewerThrottleGroup getThrottleGroup(U32 bandwidth_kbps);
  70. LL_INLINE const char* getSettingName() const
  71. {
  72. return mBWSettingName.c_str();
  73. }
  74. protected:
  75. LLViewerThrottleGroup mCurrent;
  76. LLFrameTimer mUpdateTimer;
  77. std::string mBWSettingName;
  78. std::vector<LLViewerThrottleGroup> mPresets;
  79. U32 mMaxBandwidth;
  80. U32 mCurrentBandwidth;
  81. F32 mThrottleFrac;
  82. };
  83. extern LLViewerThrottle gViewerThrottle;
  84. #endif // LL_LLVIEWERTHROTTLE_H