llinventorymodel.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLINVENTORYMODEL_H
00033 #define LL_LLINVENTORYMODEL_H
00034 
00035 #include "llassettype.h"
00036 #include "lldarray.h"
00037 #include "lluuid.h"
00038 #include "llpermissionsflags.h"
00039 #include "llstring.h"
00040 
00041 #include <map>
00042 #include <set>
00043 #include <string>
00044 #include <vector>
00045 
00046 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00047 // Class LLInventoryObserver
00048 //
00049 // This class is designed to be a simple abstract base class which can
00050 // relay messages when the inventory changes.
00051 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00052 
00053 class LLInventoryObserver
00054 {
00055 public:
00056         // This enumeration is a way to refer to what changed in a more
00057         // human readable format. You can mask the value provided by
00058         // chaged() to see if the observer is interested in the change.
00059         enum 
00060         {
00061                 NONE = 0,
00062                 LABEL = 1,                      // name changed
00063                 INTERNAL = 2,           // internal change, eg, asset uuid different
00064                 ADD = 4,                        // something added
00065                 REMOVE = 8,                     // something deleted
00066                 STRUCTURE = 16,         // structural change, eg, item or folder moved
00067                 CALLING_CARD = 32,      // online, grant status, cancel, etc change
00068                 ALL = 0xffffffff
00069         };
00070         virtual ~LLInventoryObserver() {};
00071         virtual void changed(U32 mask) = 0;
00072 };
00073 
00074 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00075 // Class LLInventoryModel
00076 //
00077 // This class represents a collection of inventory, and provides
00078 // efficient ways to access that information. This class could in
00079 // theory be used for any place where you need inventory, though it
00080 // optimizes for time efficiency - not space efficiency, probably
00081 // making it inappropriate for use on tasks.
00082 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00083 
00084 
00085 class LLInventoryObject;
00086 class LLInventoryItem;
00087 class LLInventoryCategory;
00088 class LLViewerInventoryItem;
00089 class LLViewerInventoryCategory;
00090 class LLViewerInventoryItem;
00091 class LLViewerInventoryCategory;
00092 class LLMessageSystem;
00093 class LLInventoryCollectFunctor;
00094 class LLAlertDialog;
00095 
00096 class LLInventoryModel
00097 {
00098 public:
00099         typedef enum e_has_children
00100         {
00101                 CHILDREN_NO,
00102                 CHILDREN_YES,
00103                 CHILDREN_MAYBE
00104         }EHasChildren;
00105 
00106         // These are used a lot...
00107         typedef LLDynamicArray<LLPointer<LLViewerInventoryCategory> > cat_array_t;
00108         typedef LLDynamicArray<LLPointer<LLViewerInventoryItem> > item_array_t;
00109         // construction & destruction
00110         LLInventoryModel();
00111         ~LLInventoryModel();
00112 
00113         class fetchDescendentsResponder: public LLHTTPClient::Responder
00114         {
00115                 public:
00116                         fetchDescendentsResponder(const LLSD& request_sd) : mRequestSD(request_sd) {};
00117                         void result(const LLSD& content);                       
00118                         void error(U32 status, const std::string& reason);
00119                         static void onClickRetry(S32 option, void* userdata);
00120                         static void appendRetryList(LLSD retry_sd);
00121                 public:
00122                         typedef std::vector<LLViewerInventoryCategory*> folder_ref_t;
00123                 protected:
00124                         LLSD mRequestSD;
00125                         static LLSD sRetrySD;
00126                         static LLAlertDialog            *sRetryDialog;
00127         };
00128 
00129         //
00130         // Accessors
00131         //
00132 
00133         // This is a convenience function to check if one object has a
00134         // parent chain up to the category specified by UUID.
00135         BOOL isObjectDescendentOf(const LLUUID& obj_id, const LLUUID& cat_id);
00136 
00137         // Get the object by id. Returns NULL if not found.
00138         // * WARNING: use the pointer returned for read operations - do
00139         // not modify the object values in place or you will break stuff.
00140         LLInventoryObject* getObject(const LLUUID& id) const;
00141 
00142         // Get the item by id. Returns NULL if not found.
00143         // * WARNING: use the pointer for read operations - use the
00144         // updateItem() method to actually modify values.
00145         LLViewerInventoryItem* getItem(const LLUUID& id) const;
00146 
00147         // Get the category by id. Returns NULL if not found.
00148         // * WARNING: use the pointer for read operations - use the
00149         // updateCategory() method to actually modify values.
00150         LLViewerInventoryCategory* getCategory(const LLUUID& id) const;
00151 
00152         // Return the number of items or categories
00153         S32 getItemCount() const;
00154         S32 getCategoryCount() const;
00155 
00156         // Return the direct descendents of the id provided.Set passed
00157         // in values to NULL if the call fails.
00158         // *WARNING: The array provided points straight into the guts of
00159         // this object, and should only be used for read operations, since
00160         // modifications may invalidate the internal state of the
00161         // inventory.
00162         void getDirectDescendentsOf(const LLUUID& cat_id,
00163                                                                 cat_array_t*& categories,
00164                                                                 item_array_t*& items) const;
00165 
00166         // Starting with the object specified, add it's descendents to the
00167         // array provided, but do not add the inventory object specified
00168         // by id. There is no guaranteed order. Neither array will be
00169         // erased before adding objects to it. Do not store a copy of the
00170         // pointers collected - use them, and collect them again later if
00171         // you need to reference the same objects.
00172         enum { EXCLUDE_TRASH = FALSE, INCLUDE_TRASH = TRUE };
00173         void collectDescendents(const LLUUID& id,
00174                                                         cat_array_t& categories,
00175                                                         item_array_t& items,
00176                                                         BOOL include_trash);
00177 
00178         void collectDescendentsIf(const LLUUID& id,
00179                                                           cat_array_t& categories,
00180                                                           item_array_t& items,
00181                                                           BOOL include_trash,
00182                                                           LLInventoryCollectFunctor& add);
00183 
00184         // This method will return false if this inventory model is in an usabel state.
00185         // The inventory model usage is sensitive to the initial construction of the 
00186         // model. 
00187         bool isInventoryUsable();
00188 
00189         //
00190         // Mutators
00191         //
00192 
00193         // Calling this method with an inventory item will either change
00194         // an existing item with a matching item_id, or will add the item
00195         // to the current inventory. Returns the change mask generated by
00196         // the update. No notifcation will be sent to observers. This
00197         // method will only generate network traffic if the item had to be
00198         // reparented.
00199         // *NOTE: In usage, you will want to perform cache accounting
00200         // operations in LLInventoryModel::accountForUpdate() or
00201         // LLViewerInventoryItem::updateServer() before calling this
00202         // method.
00203         U32 updateItem(const LLViewerInventoryItem* item);
00204 
00205         // Calling this method with an inventory category will either
00206         // change an existing item with the matching id, or it will add
00207         // the category. No notifcation will be sent to observers. This
00208         // method will only generate network traffic if the item had to be
00209         // reparented.
00210         // *NOTE: In usage, you will want to perform cache accounting
00211         // operations in LLInventoryModel::accountForUpdate() or
00212         // LLViewerInventoryCategory::updateServer() before calling this
00213         // method.
00214         void updateCategory(const LLViewerInventoryCategory* cat);
00215 
00216         // This method will move the specified object id to the specified
00217         // category, update the internal structures. No cache accounting,
00218         // observer notification, or server update is performed.
00219         void moveObject(const LLUUID& object_id, const LLUUID& cat_id);
00220 
00221         // delete a particular inventory object by ID. This will purge one
00222         // object from the internal data structures maintaining a
00223         // cosistent internal state. No cache accounting, observer
00224         // notification, or server update is performed.
00225         void deleteObject(const LLUUID& id);
00226 
00227         // This is a method which collects the descendents of the id
00228         // provided. If the category is not found, no action is
00229         // taken. This method goes through the long winded process of
00230         // removing server representation of folders and items while doing
00231         // cache accounting in a fairly efficient manner. This method does
00232         // not notify observers (though maybe it shouldd...)
00233         void purgeDescendentsOf(const LLUUID& id);
00234 
00235         // This method optimally removes the referenced categories and
00236         // items from the current agent's inventory in the database. It
00237         // performs all of the during deletion. The local representation
00238         // is not removed.
00239         void deleteFromServer(LLDynamicArray<LLUUID>& category_ids,
00240                                                   LLDynamicArray<LLUUID>& item_ids);
00241 
00242         // Add/remove an observer. If the observer is destroyed, be sure
00243         // to remove it.
00244         void addObserver(LLInventoryObserver* observer);
00245         void removeObserver(LLInventoryObserver* observer);
00246         BOOL containsObserver(LLInventoryObserver* observer);
00247 
00248         //
00249         // Misc Methods 
00250         //
00251 
00252         // findCategoryUUIDForType() returns the uuid of the category that
00253         // specifies 'type' as what it defaults to containing. The
00254         // category is not necessarily only for that type. *NOTE: This
00255         // will create a new inventory category on the fly if one does not
00256         // exist.
00257 
00258         // SDK: Added flag to specify whether the folder should be created if not found.  This fixes the horrible
00259         // multiple trash can bug.
00260         LLUUID findCategoryUUIDForType(LLAssetType::EType preferred_type, bool create_folder = true);
00261 
00262         // Call this method when it's time to update everyone on a new
00263         // state, by default, the inventory model will not update
00264         // observers automatically.
00265         void notifyObservers();
00266 
00267         // This allows outsiders to tell the inventory if something has
00268         // been changed 'under the hood', but outside the control of the
00269         // inventory. For example, if we grant someone modify permissions,
00270         // then that changes the data structures for LLAvatarTracker, but
00271         // potentially affects inventory observers. This API makes sure
00272         // that the next notify will include that notification.
00273         void addChangedMask(U32 mask, const LLUUID& referent);
00274 
00275         const std::set<LLUUID>& getChangedIDs() { return mChangedItemIDs; }
00276 
00277         // This method to prepares a set of mock inventory which provides
00278         // minimal functionality before the actual arrival of inventory.
00279         //void mock(const LLUUID& root_id);
00280 
00281         // make sure we have the descendents in the structure.
00282         void fetchDescendentsOf(const LLUUID& folder_id);
00283         
00284         // Add categories to a list to be fetched in bulk.
00285         static void bulkFetch(std::string url);
00286 
00287         // call this method to request the inventory.
00288         //void requestFromServer(const LLUUID& agent_id);
00289 
00290         // call this method on logout to save a terse representation
00291         void cache(const LLUUID& parent_folder_id, const LLUUID& agent_id);
00292 
00293         // Generates a string containing the path to the item specified by
00294         // item_id.
00295         void appendPath(const LLUUID& id, LLString& path);
00296 
00297         // message handling functionality
00298         static void registerCallbacks(LLMessageSystem* msg);
00299 
00300         // Convenience function to create a new category. You could call
00301         // updateCatgory() with a newly generated UUID category, but this
00302         // version will take care of details like what the name should be
00303         // based on preferred type. Returns the UUID of the new
00304         // category. If you want to use the default name based on type,
00305         // pass in a NULL to the 'name parameter.
00306         LLUUID createNewCategory(const LLUUID& parent_id,
00307                                                          LLAssetType::EType preferred_type,
00308                                                          const LLString& name);
00309 
00310         // methods to load up inventory skeleton & meat. These are used
00311         // during authentication. return true if everything parsed.
00312         typedef std::map<std::string, std::string> response_t;
00313         typedef std::vector<response_t> options_t;
00314         bool loadSkeleton(const options_t& options, const LLUUID& owner_id);
00315         bool loadMeat(const options_t& options, const LLUUID& owner_id);
00316 
00317         // This is a brute force method to rebuild the entire parent-child
00318         // relations.
00319         void buildParentChildMap();
00320 
00321         //
00322         // Category accounting.
00323         //
00324 
00325         // This structure represents the number of items added or removed
00326         // from a category.
00327         struct LLCategoryUpdate
00328         {
00329                 LLCategoryUpdate() : mDescendentDelta(0) {}
00330                 LLCategoryUpdate(const LLUUID& category_id, S32 delta) :
00331                         mCategoryID(category_id),
00332                         mDescendentDelta(delta) {}
00333                 LLUUID mCategoryID;
00334                 S32 mDescendentDelta;
00335         };
00336         typedef std::vector<LLCategoryUpdate> update_list_t;
00337 
00338         // This structure eixts to make it easier to account for deltas in
00339         // a map.
00340         struct LLInitializedS32
00341         {
00342                 LLInitializedS32() : mValue(0) {}
00343                 LLInitializedS32(S32 value) : mValue(value) {}
00344                 S32 mValue;
00345                 LLInitializedS32& operator++() { ++mValue; return *this; }
00346                 LLInitializedS32& operator--() { --mValue; return *this; }
00347         };
00348         typedef std::map<LLUUID, LLInitializedS32> update_map_t;
00349 
00350         // Call these methods when there are category updates, but call
00351         // them *before* the actual update so the method can do descendent
00352         // accounting correctly.
00353         void accountForUpdate(const LLCategoryUpdate& update);
00354         void accountForUpdate(const update_list_t& updates);
00355         void accountForUpdate(const update_map_t& updates);
00356 
00357         // Return child status of category children. yes/no/maybe
00358         EHasChildren categoryHasChildren(const LLUUID& cat_id) const;
00359 
00360         // returns true iff category version is known and theoretical
00361         // descendents == actual descendents.
00362         bool isCategoryComplete(const LLUUID& cat_id) const;
00363 
00364         // start and stop background breadth-first fetching of inventory contents
00365         // this gets triggered when performing a filter-search
00366         static void startBackgroundFetch(const LLUUID& cat_id = LLUUID::null); // start fetch process
00367         static void stopBackgroundFetch(); // stop fetch process
00368         static BOOL backgroundFetchActive();
00369         static bool isEverythingFetched();
00370         static void backgroundFetch(void*); // background fetch idle function
00371         static void incrBulkFetch(S16 fetching) {  sBulkFetchCount+=fetching; if (sBulkFetchCount<0) sBulkFetchCount=0; }
00372 protected:
00373 
00374         // Internal methods which add inventory and make sure that all of
00375         // the internal data structures are consistent. These methods
00376         // should be passed pointers of newly created objects, and the
00377         // instance will take over the memory management from there.
00378         void addCategory(LLViewerInventoryCategory* category);
00379         void addItem(LLViewerInventoryItem* item);
00380 
00381         // Internal method which looks for a category with the specified
00382         // preferred type. Returns LLUUID::null if not found
00383         LLUUID findCatUUID(LLAssetType::EType preferred_type);
00384 
00385         // Empty the entire contents
00386         void empty();
00387 
00388         // Given the current state of the inventory items, figure out the
00389         // clone information. *FIX: This is sub-optimal, since we can
00390         // insert this information snurgically, but this makes sure the
00391         // implementation works before we worry about optimization.
00392         //void recalculateCloneInformation();
00393 
00394         // file import/export.
00395         static bool loadFromFile(
00396                 const char* filename,
00397                 cat_array_t& categories,
00398                 item_array_t& items); 
00399         static bool saveToFile(
00400                 const char* filename,
00401                 const cat_array_t& categories,
00402                 const item_array_t& items); 
00403 
00404         // message handling functionality
00405         //static void processUseCachedInventory(LLMessageSystem* msg, void**);
00406         static void processUpdateCreateInventoryItem(LLMessageSystem* msg, void**);
00407         static void processRemoveInventoryItem(LLMessageSystem* msg, void**);
00408         static void processUpdateInventoryFolder(LLMessageSystem* msg, void**);
00409         static void processRemoveInventoryFolder(LLMessageSystem* msg, void**);
00410         //static void processExchangeCallingcard(LLMessageSystem* msg, void**);
00411         //static void processAddCallingcard(LLMessageSystem* msg, void**);
00412         //static void processDeclineCallingcard(LLMessageSystem* msg, void**);
00413         static void processSaveAssetIntoInventory(LLMessageSystem* msg, void**);
00414         static void processBulkUpdateInventory(LLMessageSystem* msg, void**);
00415         static void processInventoryDescendents(LLMessageSystem* msg, void**);
00416         static void processMoveInventoryItem(LLMessageSystem* msg, void**);
00417         static void processFetchInventoryReply(LLMessageSystem* msg, void**);
00418         static bool isBulkFetchProcessingComplete();
00419         
00420         bool messageUpdateCore(LLMessageSystem* msg, bool do_accounting);
00421 
00422 protected:
00423         // Varaibles used to track what has changed since the last notify.
00424         U32 mModifyMask;
00425         typedef std::set<LLUUID> changed_items_t;
00426         changed_items_t mChangedItemIDs;
00427 
00428         // Information for tracking the actual inventory. We index this
00429         // information in a lot of different ways so we can access
00430         // the inventory using several different identifiers.
00431         // mInventory member data is the 'master' list of inventory, and
00432         // mCategoryMap and mItemMap store uuid->object mappings. 
00433         typedef std::map<LLUUID, LLPointer<LLViewerInventoryCategory> > cat_map_t;
00434         typedef std::map<LLUUID, LLPointer<LLViewerInventoryItem> > item_map_t;
00435         //inv_map_t mInventory;
00436         cat_map_t mCategoryMap;
00437         item_map_t mItemMap;
00438 
00439         // cache recent lookups
00440         mutable LLPointer<LLViewerInventoryItem> mLastItem;
00441 
00442         // This last set of indices is used to map parents to children.
00443         typedef std::map<LLUUID, cat_array_t*> parent_cat_map_t;
00444         typedef std::map<LLUUID, item_array_t*> parent_item_map_t;
00445         parent_cat_map_t mParentChildCategoryTree;
00446         parent_item_map_t mParentChildItemTree;
00447 
00448         typedef std::set<LLInventoryObserver*> observer_list_t;
00449         observer_list_t mObservers;
00450 
00451         // completing the fetch once per session should be sufficient
00452         static cat_map_t sBulkFetchMap;
00453         static BOOL sBackgroundFetchActive;
00454         static BOOL sTimelyFetchPending;
00455         static BOOL sAllFoldersFetched; 
00456         static BOOL sFullFetchStarted;
00457         static S32  sNumFetchRetries;
00458         static LLFrameTimer sFetchTimer;
00459         static F32 sMinTimeBetweenFetches;
00460         static F32 sMaxTimeBetweenFetches;
00461         static S16 sBulkFetchCount;
00462 
00463         // This flag is used to handle an invalid inventory state.
00464         bool mIsAgentInvUsable;
00465 
00466 public:
00467         // *NOTE: DEBUG functionality
00468         void dumpInventory();
00469 };
00470 
00471 // a special inventory model for the agent
00472 extern LLInventoryModel gInventory;
00473 
00474 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00475 // Class LLInventoryCollectFunctor
00476 //
00477 // Base class for LLInventoryModel::collectDescendentsIf() method
00478 // which accepts an instance of one of these objects to use as the
00479 // function to determine if it should be added. Derive from this class
00480 // and override the () operator to return TRUE if you want to collect
00481 // the category or item passed in.
00482 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00483 
00484 class LLInventoryCollectFunctor
00485 {
00486 public:
00487         virtual ~LLInventoryCollectFunctor(){};
00488         virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item) = 0;
00489 };
00490 
00491 
00492 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00493 // Class LLAssetIDMatches
00494 //
00495 // This functor finds inventory items pointing to the specified asset
00496 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00497 class LLViewerInventoryItem;
00498 
00499 class LLAssetIDMatches : public LLInventoryCollectFunctor
00500 {
00501 public:
00502         LLAssetIDMatches(const LLUUID& asset_id) : mAssetID(asset_id) {}
00503         virtual ~LLAssetIDMatches() {}
00504         bool operator()(LLInventoryCategory* cat, LLInventoryItem* item);
00505         
00506 protected:
00507         LLUUID mAssetID;
00508 };
00509 
00510 
00511 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00512 // Class LLIsType
00513 //
00514 // Implementation of a LLInventoryCollectFunctor which returns TRUE if
00515 // the type is the type passed in during construction.
00516 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00517 
00518 class LLIsType : public LLInventoryCollectFunctor
00519 {
00520 public:
00521         LLIsType(LLAssetType::EType type) : mType(type) {}
00522         virtual ~LLIsType() {}
00523         virtual bool operator()(LLInventoryCategory* cat,
00524                                                         LLInventoryItem* item);
00525 protected:
00526         LLAssetType::EType mType;
00527 };
00528 
00529 
00530 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00531 // Class LLIsNotType
00532 //
00533 // Implementation of a LLInventoryCollectFunctor which returns FALSE if the
00534 // type is the type passed in during construction, otherwise false.
00535 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00536 
00537 class LLIsNotType : public LLInventoryCollectFunctor
00538 {
00539 public:
00540         LLIsNotType(LLAssetType::EType type) : mType(type) {}
00541         virtual ~LLIsNotType() {}
00542         virtual bool operator()(LLInventoryCategory* cat,
00543                                                         LLInventoryItem* item);
00544 protected:
00545         LLAssetType::EType mType;
00546 };
00547 
00548 class LLIsTypeWithPermissions : public LLInventoryCollectFunctor
00549 {
00550 public:
00551         LLIsTypeWithPermissions(LLAssetType::EType type, const PermissionBit perms, const LLUUID &agent_id, const LLUUID &group_id) 
00552                 : mType(type), mPerm(perms), mAgentID(agent_id), mGroupID(group_id) {}
00553         virtual ~LLIsTypeWithPermissions() {}
00554         virtual bool operator()(LLInventoryCategory* cat,
00555                                                         LLInventoryItem* item);
00556 protected:
00557         LLAssetType::EType mType;
00558         PermissionBit mPerm;
00559         LLUUID                  mAgentID;
00560         LLUUID                  mGroupID;
00561 };
00562 
00563 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00564 // Class LLIsClone
00565 //
00566 // Implementation of a LLInventoryCollectFunctor which returns TRUE if
00567 // the object is a clone of the item passed in during
00568 // construction.
00569 //
00570 // *NOTE: Since clone information is determined based off of asset id
00571 // (or creator with calling cards), if the id is NULL, it has no
00572 // clones - even itself.
00573 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00574 
00575 //class LLIsClone : public LLInventoryCollectFunctor
00576 //{
00577 //public:
00578 //      LLIsClone(LLViewerInventoryItem* item) : mItem(item) {}
00579 //      virtual ~LLIsClone() {}
00580 //      virtual bool operator()(LLViewerInventoryCategory* cat,
00581 //                                                      LLViewerInventoryItem* item);
00582 //protected:
00583 //      LLPointer<LLViewerInventoryItem> mItem;
00584 //};
00585 
00586 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00587 // Class LLBuddyCollector
00588 //
00589 // Simple class that collects calling cards that are not null, and not
00590 // the agent. Duplicates are possible.
00591 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00592 
00593 class LLBuddyCollector : public LLInventoryCollectFunctor
00594 {
00595 public:
00596         LLBuddyCollector() {}
00597         virtual ~LLBuddyCollector() {}
00598         virtual bool operator()(LLInventoryCategory* cat,
00599                                                         LLInventoryItem* item);
00600 };
00601 
00602 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00603 // Class LLUniqueBuddyCollector
00604 //
00605 // Simple class that collects calling cards that are not null, and not
00606 // the agent. Duplicates are discarded.
00607 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00608 
00609 class LLUniqueBuddyCollector : public LLInventoryCollectFunctor
00610 {
00611 public:
00612         LLUniqueBuddyCollector() {}
00613         virtual ~LLUniqueBuddyCollector() {}
00614         virtual bool operator()(LLInventoryCategory* cat,
00615                                                         LLInventoryItem* item);
00616 
00617 protected:
00618         std::set<LLUUID> mSeen;
00619 };
00620 
00621 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00622 // Class LLParticularBuddyCollector
00623 //
00624 // Simple class that collects calling cards that match a particular uuid
00625 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00626 
00627 class LLParticularBuddyCollector : public LLInventoryCollectFunctor
00628 {
00629 public:
00630         LLParticularBuddyCollector(const LLUUID& id) : mBuddyID(id) {}
00631         virtual ~LLParticularBuddyCollector() {}
00632         virtual bool operator()(LLInventoryCategory* cat,
00633                                                         LLInventoryItem* item);
00634 protected:
00635         LLUUID mBuddyID;
00636 };
00637 
00638 
00639 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00640 // Class LLNameCategoryCollector
00641 //
00642 // Collects categories based on case-insensitive match of prefix
00643 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00644 
00645 class LLNameCategoryCollector : public LLInventoryCollectFunctor
00646 {
00647 public:
00648         LLNameCategoryCollector(const char* name) : mName(name) {}
00649         virtual ~LLNameCategoryCollector() {}
00650         virtual bool operator()(LLInventoryCategory* cat,
00651                                                         LLInventoryItem* item);
00652 protected:
00653         std::string mName;
00654 };
00655 
00656 
00657 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00658 // Class LLInventoryCompletionObserver
00659 //
00660 // Class which can be used as a base class for doing something when
00661 // when all observed items are locally complete. This class implements
00662 // the changed() method of LLInventoryObserver and declares a new
00663 // method named done() which is called when all watched items have
00664 // complete information in the inventory model.
00665 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00666 
00667 class LLInventoryCompletionObserver : public LLInventoryObserver
00668 {
00669 public:
00670         LLInventoryCompletionObserver() {}
00671         virtual void changed(U32 mask);
00672 
00673         void watchItem(const LLUUID& id);
00674 
00675 protected:
00676         virtual void done() = 0;
00677 
00678         typedef std::vector<LLUUID> item_ref_t;
00679         item_ref_t mComplete;
00680         item_ref_t mIncomplete;
00681 };
00682 
00683 
00684 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00685 // Class LLInventoryFetchObserver
00686 //
00687 // This class is much like the LLInventoryCompletionObserver, except
00688 // that it handles all the the fetching necessary. Override the done()
00689 // method to do the thing you want.
00690 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00691 
00692 class LLInventoryFetchObserver : public LLInventoryObserver
00693 {
00694 public:
00695         LLInventoryFetchObserver() {}
00696         virtual void changed(U32 mask);
00697 
00698         typedef std::vector<LLUUID> item_ref_t;
00699 
00700         bool isEverythingComplete() const;
00701         void fetchItems(const item_ref_t& ids);
00702         virtual void done() = 0;
00703 
00704 protected:
00705         item_ref_t mComplete;
00706         item_ref_t mIncomplete;
00707 };
00708 
00709 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00710 // Class LLInventoryFetchDescendentsObserver
00711 //
00712 // This class is much like the LLInventoryCompletionObserver, except
00713 // that it handles fetching based on category. Override the done()
00714 // method to do the thing you want.
00715 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00716 class LLInventoryFetchDescendentsObserver : public LLInventoryObserver
00717 {
00718 public:
00719         LLInventoryFetchDescendentsObserver() {}
00720         virtual void changed(U32 mask);
00721 
00722         typedef std::vector<LLUUID> folder_ref_t;
00723         void fetchDescendents(const folder_ref_t& ids);
00724         bool isEverythingComplete() const;
00725         virtual void done() = 0;
00726 
00727 protected:
00728         bool isComplete(LLViewerInventoryCategory* cat);
00729         folder_ref_t mIncompleteFolders;
00730         folder_ref_t mCompleteFolders;
00731 };
00732 
00733 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00734 // Class LLInventoryFetchComboObserver
00735 //
00736 // This class does an appropriate combination of fetch descendents and
00737 // item fetches based on completion of categories and items. Much like
00738 // the fetch and fetch descendents, this will call done() when everything
00739 // has arrived.
00740 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00741 class LLInventoryFetchComboObserver : public LLInventoryObserver
00742 {
00743 public:
00744         LLInventoryFetchComboObserver() : mDone(false) {}
00745         virtual void changed(U32 mask);
00746 
00747         typedef std::vector<LLUUID> folder_ref_t;
00748         typedef std::vector<LLUUID> item_ref_t;
00749         void fetch(const folder_ref_t& folder_ids, const item_ref_t& item_ids);
00750 
00751         virtual void done() = 0;
00752 
00753 protected:
00754         bool mDone;
00755         folder_ref_t mCompleteFolders;
00756         folder_ref_t mIncompleteFolders;
00757         item_ref_t mCompleteItems;
00758         item_ref_t mIncompleteItems;
00759 };
00760 
00761 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00762 // Class LLInventoryExistenceObserver
00763 //
00764 // This class is used as a base class for doing somethign when all the
00765 // observed item ids exist in the inventory somewhere. You can derive
00766 // a class from this class and implement the done() method to do
00767 // something useful.
00768 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00769 
00770 class LLInventoryExistenceObserver : public LLInventoryObserver
00771 {
00772 public:
00773         LLInventoryExistenceObserver() {}
00774         virtual void changed(U32 mask);
00775 
00776         void watchItem(const LLUUID& id);
00777 
00778 protected:
00779         virtual void done() = 0;
00780 
00781         typedef std::vector<LLUUID> item_ref_t;
00782         item_ref_t mExist;
00783         item_ref_t mMIA;
00784 };
00785 
00786 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00787 // Class LLInventoryAddedObserver
00788 //
00789 // This class is used as a base class for doing something when 
00790 // a new item arrives in inventory.
00791 // It does not watch for a certain UUID, rather it acts when anything is added
00792 // Derive a class from this class and implement the done() method to do
00793 // something useful.
00794 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00795 
00796 class LLInventoryAddedObserver : public LLInventoryObserver
00797 {
00798 public:
00799         LLInventoryAddedObserver() : mAdded() {}
00800         virtual void changed(U32 mask);
00801 
00802 protected:
00803         virtual void done() = 0;
00804 
00805         typedef std::vector<LLUUID> item_ref_t;
00806         item_ref_t mAdded;
00807 };
00808 
00809 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00810 // Class LLInventoryTransactionObserver
00811 //
00812 // Class which can be used as a base class for doing something when an
00813 // inventory transaction completes.
00814 //
00815 // *NOTE: This class is not quite complete. Avoid using unless you fix up it's
00816 // functionality gaps.
00817 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00818 
00819 class LLInventoryTransactionObserver : public LLInventoryObserver
00820 {
00821 public:
00822         LLInventoryTransactionObserver(const LLTransactionID& transaction_id);
00823         virtual void changed(U32 mask);
00824 
00825 protected:
00826         typedef std::vector<LLUUID> folder_ref_t;
00827         typedef std::vector<LLUUID> item_ref_t;
00828         virtual void done(const folder_ref_t& folders, const item_ref_t& items) = 0;
00829 
00830         LLTransactionID mTransactionID;
00831 };
00832 
00833 
00834 #endif // LL_LLINVENTORYMODEL_H
00835 

Generated on Fri May 16 08:33:43 2008 for SecondLife by  doxygen 1.5.5