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(FILE* fp) const;
00095         BOOL importFile(FILE* 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         // message serialization
00107         void packMessage(LLMessageSystem* msg) const;
00108         void unpackMessage(LLMessageSystem* msg, const char* block);
00109         void unpackMultiMessage(LLMessageSystem* msg, const char* block,
00110                                                         S32 block_num);
00111 
00112         // static functionality for determine for sale status.
00113         static EForSale lookup(const char* name);
00114         static const char* lookup(EForSale type);
00115 
00116         // Allow accumulation of sale info. The price of each is added,
00117         // conflict in sale type results in FS_NOT, and the permissions
00118         // are tightened.
00119         void accumulate(const LLSaleInfo& sale_info);
00120 
00121         bool operator==(const LLSaleInfo &rhs) const;
00122         bool operator!=(const LLSaleInfo &rhs) const;
00123 };
00124 
00125 // These functions convert between structured data and sale info as
00126 // appropriate for serialization.
00127 LLSD ll_create_sd_from_sale_info(const LLSaleInfo& sale);
00128 LLSaleInfo ll_sale_info_from_sd(const LLSD& sd);
00129 
00130 #endif // LL_LLSALEINFO_H

Generated on Thu Jul 1 06:09:05 2010 for Second Life Viewer by  doxygen 1.4.7