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