PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llinventory/lleconomy.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 159 lines | 100 code | 29 blank | 30 comment | 0 complexity | 70c9a66601b0e9379e1e9197ed427773 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lleconomy.h
  3. *
  4. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  5. * Second Life Viewer Source Code
  6. * Copyright (C) 2010, Linden Research, Inc.
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation;
  11. * version 2.1 of the License only.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  23. * $/LicenseInfo$
  24. */
  25. #ifndef LL_LLECONOMY_H
  26. #define LL_LLECONOMY_H
  27. #include "llsingleton.h"
  28. class LLMessageSystem;
  29. class LLVector3;
  30. /**
  31. * Register an observer to be notified of economy data updates coming from server.
  32. */
  33. class LLEconomyObserver
  34. {
  35. public:
  36. virtual ~LLEconomyObserver() {}
  37. virtual void onEconomyDataChange() = 0;
  38. };
  39. class LLGlobalEconomy
  40. {
  41. public:
  42. LLGlobalEconomy();
  43. virtual ~LLGlobalEconomy();
  44. // This class defines its singleton internally as a typedef instead of inheriting from
  45. // LLSingleton like most others because the LLRegionEconomy sub-class might also
  46. // become a singleton and this pattern will more easily disambiguate them.
  47. typedef LLSingleton<LLGlobalEconomy> Singleton;
  48. void initSingleton() { }
  49. virtual void print();
  50. void addObserver(LLEconomyObserver* observer);
  51. void removeObserver(LLEconomyObserver* observer);
  52. void notifyObservers();
  53. static void processEconomyData(LLMessageSystem *msg, LLGlobalEconomy* econ_data);
  54. S32 calculateTeleportCost(F32 distance) const;
  55. S32 calculateLightRent(const LLVector3& object_size) const;
  56. S32 getObjectCount() const { return mObjectCount; }
  57. S32 getObjectCapacity() const { return mObjectCapacity; }
  58. S32 getPriceObjectClaim() const { return mPriceObjectClaim; }
  59. S32 getPricePublicObjectDecay() const { return mPricePublicObjectDecay; }
  60. S32 getPricePublicObjectDelete() const { return mPricePublicObjectDelete; }
  61. S32 getPricePublicObjectRelease() const { return mPriceObjectClaim - mPricePublicObjectDelete; }
  62. S32 getPriceEnergyUnit() const { return mPriceEnergyUnit; }
  63. S32 getPriceUpload() const { return mPriceUpload; }
  64. S32 getPriceRentLight() const { return mPriceRentLight; }
  65. S32 getTeleportMinPrice() const { return mTeleportMinPrice; }
  66. F32 getTeleportPriceExponent() const { return mTeleportPriceExponent; }
  67. S32 getPriceGroupCreate() const { return mPriceGroupCreate; }
  68. void setObjectCount(S32 val) { mObjectCount = val; }
  69. void setObjectCapacity(S32 val) { mObjectCapacity = val; }
  70. void setPriceObjectClaim(S32 val) { mPriceObjectClaim = val; }
  71. void setPricePublicObjectDecay(S32 val) { mPricePublicObjectDecay = val; }
  72. void setPricePublicObjectDelete(S32 val) { mPricePublicObjectDelete = val; }
  73. void setPriceEnergyUnit(S32 val) { mPriceEnergyUnit = val; }
  74. void setPriceUpload(S32 val) { mPriceUpload = val; }
  75. void setPriceRentLight(S32 val) { mPriceRentLight = val; }
  76. void setTeleportMinPrice(S32 val) { mTeleportMinPrice = val; }
  77. void setTeleportPriceExponent(F32 val) { mTeleportPriceExponent = val; }
  78. void setPriceGroupCreate(S32 val) { mPriceGroupCreate = val; }
  79. private:
  80. S32 mObjectCount;
  81. S32 mObjectCapacity;
  82. S32 mPriceObjectClaim; // per primitive
  83. S32 mPricePublicObjectDecay; // per primitive
  84. S32 mPricePublicObjectDelete; // per primitive
  85. S32 mPriceEnergyUnit;
  86. S32 mPriceUpload;
  87. S32 mPriceRentLight;
  88. S32 mTeleportMinPrice;
  89. F32 mTeleportPriceExponent;
  90. S32 mPriceGroupCreate;
  91. std::list<LLEconomyObserver*> mObservers;
  92. };
  93. class LLRegionEconomy : public LLGlobalEconomy
  94. {
  95. public:
  96. LLRegionEconomy();
  97. ~LLRegionEconomy();
  98. static void processEconomyData(LLMessageSystem *msg, void **user_data);
  99. static void processEconomyDataRequest(LLMessageSystem *msg, void **user_data);
  100. void print();
  101. BOOL hasData() const;
  102. F32 getPriceObjectRent() const { return mPriceObjectRent; }
  103. F32 getPriceObjectScaleFactor() const {return mPriceObjectScaleFactor;}
  104. F32 getEnergyEfficiency() const { return mEnergyEfficiency; }
  105. S32 getPriceParcelClaim() const;
  106. S32 getPriceParcelRent() const;
  107. F32 getAreaOwned() const { return mAreaOwned; }
  108. F32 getAreaTotal() const { return mAreaTotal; }
  109. S32 getBasePriceParcelClaimActual() const { return mBasePriceParcelClaimActual; }
  110. void setPriceObjectRent(F32 val) { mPriceObjectRent = val; }
  111. void setPriceObjectScaleFactor(F32 val) { mPriceObjectScaleFactor = val; }
  112. void setEnergyEfficiency(F32 val) { mEnergyEfficiency = val; }
  113. void setBasePriceParcelClaimDefault(S32 val);
  114. void setBasePriceParcelClaimActual(S32 val);
  115. void setPriceParcelClaimFactor(F32 val);
  116. void setBasePriceParcelRent(S32 val);
  117. void setAreaOwned(F32 val) { mAreaOwned = val; }
  118. void setAreaTotal(F32 val) { mAreaTotal = val; }
  119. private:
  120. F32 mPriceObjectRent;
  121. F32 mPriceObjectScaleFactor;
  122. F32 mEnergyEfficiency;
  123. S32 mBasePriceParcelClaimDefault;
  124. S32 mBasePriceParcelClaimActual;
  125. F32 mPriceParcelClaimFactor;
  126. S32 mBasePriceParcelRent;
  127. F32 mAreaOwned;
  128. F32 mAreaTotal;
  129. };
  130. #endif