PageRenderTime 22ms CodeModel.GetById 12ms app.highlight 7ms 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
  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
 26#ifndef LL_LLECONOMY_H
 27#define LL_LLECONOMY_H
 28
 29#include "llsingleton.h"
 30
 31class LLMessageSystem;
 32class LLVector3;
 33
 34/**
 35 * Register an observer to be notified of economy data updates coming from server.
 36 */
 37class LLEconomyObserver
 38{
 39public:
 40	virtual ~LLEconomyObserver() {}
 41	virtual void onEconomyDataChange() = 0;
 42};
 43
 44class LLGlobalEconomy
 45{
 46public:
 47	LLGlobalEconomy();
 48	virtual ~LLGlobalEconomy();
 49
 50	// This class defines its singleton internally as a typedef instead of inheriting from
 51	// LLSingleton like most others because the LLRegionEconomy sub-class might also
 52	// become a singleton and this pattern will more easily disambiguate them.
 53	typedef LLSingleton<LLGlobalEconomy> Singleton;
 54
 55	void initSingleton() { }
 56
 57	virtual void print();
 58
 59	void	addObserver(LLEconomyObserver* observer);
 60	void	removeObserver(LLEconomyObserver* observer);
 61	void	notifyObservers();
 62
 63	static void processEconomyData(LLMessageSystem *msg, LLGlobalEconomy* econ_data);
 64
 65	S32		calculateTeleportCost(F32 distance) const;
 66	S32		calculateLightRent(const LLVector3& object_size) const;
 67
 68	S32		getObjectCount() const				{ return mObjectCount; }
 69	S32		getObjectCapacity() const			{ return mObjectCapacity; }
 70	S32		getPriceObjectClaim() const			{ return mPriceObjectClaim; }
 71	S32		getPricePublicObjectDecay() const	{ return mPricePublicObjectDecay; }
 72	S32		getPricePublicObjectDelete() const	{ return mPricePublicObjectDelete; }
 73	S32		getPricePublicObjectRelease() const	{ return mPriceObjectClaim - mPricePublicObjectDelete; }
 74	S32		getPriceEnergyUnit() const			{ return mPriceEnergyUnit; }
 75	S32		getPriceUpload() const				{ return mPriceUpload; }
 76	S32		getPriceRentLight() const			{ return mPriceRentLight; }
 77	S32		getTeleportMinPrice() const			{ return mTeleportMinPrice; }
 78	F32		getTeleportPriceExponent() const 	{ return mTeleportPriceExponent; }
 79	S32		getPriceGroupCreate() const			{ return mPriceGroupCreate; }
 80
 81
 82	void	setObjectCount(S32 val)				{ mObjectCount = val; }
 83	void	setObjectCapacity(S32 val)			{ mObjectCapacity = val; }
 84	void	setPriceObjectClaim(S32 val)		{ mPriceObjectClaim = val; }
 85	void	setPricePublicObjectDecay(S32 val)	{ mPricePublicObjectDecay = val; }
 86	void	setPricePublicObjectDelete(S32 val)	{ mPricePublicObjectDelete = val; }
 87	void	setPriceEnergyUnit(S32 val)			{ mPriceEnergyUnit = val; }
 88	void	setPriceUpload(S32 val)				{ mPriceUpload = val; }
 89	void	setPriceRentLight(S32 val)			{ mPriceRentLight = val; }
 90	void	setTeleportMinPrice(S32 val)		{ mTeleportMinPrice = val; }
 91	void	setTeleportPriceExponent(F32 val) 	{ mTeleportPriceExponent = val; }
 92	void	setPriceGroupCreate(S32 val)		{ mPriceGroupCreate = val; }
 93
 94private:
 95	S32		mObjectCount;
 96	S32		mObjectCapacity;
 97	S32		mPriceObjectClaim;			// per primitive
 98	S32		mPricePublicObjectDecay;	// per primitive
 99	S32		mPricePublicObjectDelete;	// per primitive
100	S32		mPriceEnergyUnit;
101	S32		mPriceUpload;
102	S32		mPriceRentLight;
103	S32		mTeleportMinPrice;
104	F32		mTeleportPriceExponent;
105	S32     mPriceGroupCreate;
106
107	std::list<LLEconomyObserver*> mObservers;
108};
109
110
111class LLRegionEconomy : public LLGlobalEconomy
112{
113public:
114	LLRegionEconomy();
115	~LLRegionEconomy();
116
117	static void processEconomyData(LLMessageSystem *msg, void **user_data);
118	static void processEconomyDataRequest(LLMessageSystem *msg, void **user_data);
119
120	void print();
121
122	BOOL	hasData() const;
123	F32		getPriceObjectRent() const	{ return mPriceObjectRent; }
124	F32		getPriceObjectScaleFactor() const {return mPriceObjectScaleFactor;}
125	F32		getEnergyEfficiency() const	{ return mEnergyEfficiency; }
126	S32		getPriceParcelClaim() const;
127	S32		getPriceParcelRent() const;
128	F32		getAreaOwned() const		{ return mAreaOwned; }
129	F32		getAreaTotal() const		{ return mAreaTotal; }
130	S32 getBasePriceParcelClaimActual() const { return mBasePriceParcelClaimActual; }
131
132	void	setPriceObjectRent(F32 val)			{ mPriceObjectRent = val; }
133	void	setPriceObjectScaleFactor(F32 val) { mPriceObjectScaleFactor = val; }
134	void	setEnergyEfficiency(F32 val)		{ mEnergyEfficiency = val; }
135
136	void setBasePriceParcelClaimDefault(S32 val);
137	void setBasePriceParcelClaimActual(S32 val);
138	void setPriceParcelClaimFactor(F32 val);
139	void setBasePriceParcelRent(S32 val);
140
141	void	setAreaOwned(F32 val)				{ mAreaOwned = val; }
142	void	setAreaTotal(F32 val)				{ mAreaTotal = val; }
143
144private:
145	F32		mPriceObjectRent;
146	F32		mPriceObjectScaleFactor;
147	F32		mEnergyEfficiency;
148
149	S32	mBasePriceParcelClaimDefault;
150	S32 mBasePriceParcelClaimActual;
151	F32 mPriceParcelClaimFactor;
152	S32 mBasePriceParcelRent;
153
154	F32		mAreaOwned;
155	F32		mAreaTotal;
156
157};
158
159#endif