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

Generated on Thu Jul 1 06:08:46 2010 for Second Life Viewer by  doxygen 1.4.7