PageRenderTime 17ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llinventory/llsaleinfo.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 125 lines | 53 code | 25 blank | 47 comment | 0 complexity | b3475aa12b735b13baf7de126ed5089f MD5 | raw file
  1/** 
  2 * @file llsaleinfo.h
  3 * @brief LLSaleInfo 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_LLSALEINFO_H
 28#define LL_LLSALEINFO_H
 29
 30#include "llpermissionsflags.h"
 31#include "llsd.h"
 32#include "llxmlnode.h"
 33
 34//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 35// Class LLSaleInfo
 36//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 37
 38// L$ default price for objects
 39const S32 DEFAULT_PRICE = 10;
 40
 41class LLMessageSystem;
 42
 43class LLSaleInfo
 44{
 45public:
 46	// use this to avoid temporary object creation
 47	static const LLSaleInfo DEFAULT;
 48
 49	enum EForSale
 50	{
 51		// item is not to be considered for transactions
 52		FS_NOT = 0,
 53
 54		// the origional is on sale
 55		FS_ORIGINAL = 1,
 56
 57		// A copy is for sale
 58		FS_COPY = 2,
 59
 60		// Valid only for tasks, the inventory is for sale
 61		// at the price in this structure.
 62		FS_CONTENTS = 3,
 63
 64		FS_COUNT
 65	};
 66
 67protected:
 68	EForSale mSaleType;
 69	S32 mSalePrice;
 70
 71public:
 72	// default constructor is fine usually
 73	LLSaleInfo();
 74	LLSaleInfo(EForSale sale_type, S32 sale_price);
 75
 76	// accessors
 77	BOOL isForSale() const;
 78	EForSale getSaleType() const { return mSaleType; }
 79	S32 getSalePrice() const { return mSalePrice; }
 80	U32 getCRC32() const;
 81
 82	// mutators
 83	void setSaleType(EForSale type)		{ mSaleType = type; }
 84	void setSalePrice(S32 price);
 85	//void setNextOwnerPermMask(U32 mask)	{ mNextOwnerPermMask = mask; }
 86
 87
 88	// file serialization
 89	BOOL exportFile(LLFILE* fp) const;
 90	BOOL importFile(LLFILE* fp, BOOL& has_perm_mask, U32& perm_mask);
 91
 92	BOOL exportLegacyStream(std::ostream& output_stream) const;
 93	LLSD asLLSD() const;
 94	operator LLSD() const { return asLLSD(); }
 95	bool fromLLSD(const LLSD& sd, BOOL& has_perm_mask, U32& perm_mask);
 96	BOOL importLegacyStream(std::istream& input_stream, BOOL& has_perm_mask, U32& perm_mask);
 97
 98	LLSD packMessage() const;
 99	void unpackMessage(LLSD sales);
100
101	// message serialization
102	void packMessage(LLMessageSystem* msg) const;
103	void unpackMessage(LLMessageSystem* msg, const char* block);
104	void unpackMultiMessage(LLMessageSystem* msg, const char* block,
105							S32 block_num);
106
107	// static functionality for determine for sale status.
108	static EForSale lookup(const char* name);
109	static const char* lookup(EForSale type);
110
111	// Allow accumulation of sale info. The price of each is added,
112	// conflict in sale type results in FS_NOT, and the permissions
113	// are tightened.
114	void accumulate(const LLSaleInfo& sale_info);
115
116	bool operator==(const LLSaleInfo &rhs) const;
117	bool operator!=(const LLSaleInfo &rhs) const;
118};
119
120// These functions convert between structured data and sale info as
121// appropriate for serialization.
122LLSD ll_create_sd_from_sale_info(const LLSaleInfo& sale);
123LLSaleInfo ll_sale_info_from_sd(const LLSD& sd);
124
125#endif // LL_LLSALEINFO_H