llsaleinfo.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**
  2. * @file llsaleinfo.h
  3. * @brief LLSaleInfo 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_LLSALEINFO_H
  33. #define LL_LLSALEINFO_H
  34. #include "llpermissionsflags.h"
  35. #include "llpreprocessor.h"
  36. #include "llsd.h"
  37. #include "llxmlnode.h"
  38. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  39. // Class LLSaleInfo
  40. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  41. // L$ default price for objects
  42. constexpr S32 DEFAULT_PRICE = 10;
  43. class LLMessageSystem;
  44. class LLSaleInfo
  45. {
  46. protected:
  47. LOG_CLASS(LLSaleInfo);
  48. public:
  49. // Use this to avoid temporary object creation
  50. static const LLSaleInfo DEFAULT;
  51. enum EForSale
  52. {
  53. // Item is not to be considered for transactions
  54. FS_NOT = 0,
  55. // The origional is on sale
  56. FS_ORIGINAL = 1,
  57. // A copy is for sale
  58. FS_COPY = 2,
  59. // Valid only for tasks, the inventory is for sale at the price in this
  60. // structure.
  61. FS_CONTENTS = 3,
  62. FS_COUNT
  63. };
  64. public:
  65. // Default constructor is fine usually
  66. LLSaleInfo();
  67. LLSaleInfo(EForSale sale_type, S32 sale_price);
  68. // Accessors
  69. LL_INLINE bool isForSale() const { return mSaleType != FS_NOT; }
  70. LL_INLINE EForSale getSaleType() const { return mSaleType; }
  71. LL_INLINE S32 getSalePrice() const { return mSalePrice; }
  72. U32 getCRC32() const;
  73. // Mutators
  74. LL_INLINE void setSaleType(EForSale type) { mSaleType = type; }
  75. void setSalePrice(S32 price);
  76. #if 0
  77. LL_INLINE void setNextOwnerPermMask(U32 mask) { mNextOwnerPermMask = mask; }
  78. #endif
  79. bool exportLegacyStream(std::ostream& output_stream) const;
  80. LLSD asLLSD() const;
  81. LL_INLINE operator LLSD() const { return asLLSD(); }
  82. bool fromLLSD(const LLSD& sd, bool& has_perm_mask, U32& perm_mask);
  83. bool importLegacyStream(std::istream& input_stream, bool& has_perm_mask,
  84. U32& perm_mask);
  85. LLSD packMessage() const;
  86. void unpackMessage(LLSD sales);
  87. // Message serialization
  88. void packMessage(LLMessageSystem* msg) const;
  89. void unpackMessage(LLMessageSystem* msg, const char* block);
  90. void unpackMultiMessage(LLMessageSystem* msg, const char* block,
  91. S32 block_num);
  92. // Static functionality to determine the "for sale" status.
  93. static EForSale lookup(const char* name);
  94. static const char* lookup(EForSale type);
  95. // Allows accumulation of sale info. The price of each is added, conflict
  96. // in sale type results in FS_NOT, and the permissions are tightened.
  97. void accumulate(const LLSaleInfo& sale_info);
  98. bool operator==(const LLSaleInfo& rhs) const;
  99. bool operator!=(const LLSaleInfo& rhs) const;
  100. protected:
  101. EForSale mSaleType;
  102. S32 mSalePrice;
  103. };
  104. // These functions convert between structured data and sale info as appropriate
  105. // for serialization.
  106. LLSD ll_create_sd_from_sale_info(const LLSaleInfo& sale);
  107. LLSaleInfo ll_sale_info_from_sd(const LLSD& sd);
  108. #endif // LL_LLSALEINFO_H