llsaleinfo.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLSALEINFO_H
00033 #define LL_LLSALEINFO_H
00034 
00035 #include "llpermissionsflags.h"
00036 #include "llsd.h"
00037 #include "llxmlnode.h"
00038 
00039 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00040 // Class LLSaleInfo
00041 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00042 
00043 // L$ default price for objects
00044 const S32 DEFAULT_PRICE = 10;
00045 
00046 class LLMessageSystem;
00047 
00048 class LLSaleInfo
00049 {
00050 public:
00051         // use this to avoid temporary object creation
00052         static const LLSaleInfo DEFAULT;
00053 
00054         enum EForSale
00055         {
00056                 // item is not to be considered for transactions
00057                 FS_NOT = 0,
00058 
00059                 // the origional is on sale
00060                 FS_ORIGINAL = 1,
00061 
00062                 // A copy is for sale
00063                 FS_COPY = 2,
00064 
00065                 // Valid only for tasks, the inventory is for sale
00066                 // at the price in this structure.
00067                 FS_CONTENTS = 3,
00068 
00069                 FS_COUNT
00070         };
00071 
00072 protected:
00073         EForSale mSaleType;
00074         S32 mSalePrice;
00075 
00076 public:
00077         // default constructor is fine usually
00078         LLSaleInfo();
00079         LLSaleInfo(EForSale sale_type, S32 sale_price);
00080 
00081         // accessors
00082         BOOL isForSale() const;
00083         EForSale getSaleType() const { return mSaleType; }
00084         S32 getSalePrice() const { return mSalePrice; }
00085         U32 getCRC32() const;
00086 
00087         // mutators
00088         void setSaleType(EForSale type)         { mSaleType = type; }
00089         void setSalePrice(S32 price);
00090         //void setNextOwnerPermMask(U32 mask)   { mNextOwnerPermMask = mask; }
00091 
00092 
00093         // file serialization
00094         BOOL exportFile(LLFILE* fp) const;
00095         BOOL importFile(LLFILE* fp, BOOL& has_perm_mask, U32& perm_mask);
00096 
00097         BOOL exportLegacyStream(std::ostream& output_stream) const;
00098         LLSD asLLSD() const;
00099         operator LLSD() const { return asLLSD(); }
00100         bool fromLLSD(LLSD& sd, BOOL& has_perm_mask, U32& perm_mask);
00101         BOOL importLegacyStream(std::istream& input_stream, BOOL& has_perm_mask, U32& perm_mask);
00102 
00103         LLXMLNode *exportFileXML() const;
00104         BOOL importXML(LLXMLNode* node);
00105 
00106         LLSD packMessage() const;
00107         void unpackMessage(LLSD sales);
00108 
00109         // message serialization
00110         void packMessage(LLMessageSystem* msg) const;
00111         void unpackMessage(LLMessageSystem* msg, const char* block);
00112         void unpackMultiMessage(LLMessageSystem* msg, const char* block,
00113                                                         S32 block_num);
00114 
00115         // static functionality for determine for sale status.
00116         static EForSale lookup(const char* name);
00117         static const char* lookup(EForSale type);
00118 
00119         // Allow accumulation of sale info. The price of each is added,
00120         // conflict in sale type results in FS_NOT, and the permissions
00121         // are tightened.
00122         void accumulate(const LLSaleInfo& sale_info);
00123 
00124         bool operator==(const LLSaleInfo &rhs) const;
00125         bool operator!=(const LLSaleInfo &rhs) const;
00126 };
00127 
00128 // These functions convert between structured data and sale info as
00129 // appropriate for serialization.
00130 LLSD ll_create_sd_from_sale_info(const LLSaleInfo& sale);
00131 LLSaleInfo ll_sale_info_from_sd(const LLSD& sd);
00132 
00133 #endif // LL_LLSALEINFO_H

Generated on Fri May 16 08:32:13 2008 for SecondLife by  doxygen 1.5.5