aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llinventorymodel.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llinventorymodel.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llinventorymodel.h')
-rw-r--r--linden/indra/newview/llinventorymodel.h777
1 files changed, 777 insertions, 0 deletions
diff --git a/linden/indra/newview/llinventorymodel.h b/linden/indra/newview/llinventorymodel.h
new file mode 100644
index 0000000..d0eb2de
--- /dev/null
+++ b/linden/indra/newview/llinventorymodel.h
@@ -0,0 +1,777 @@
1/**
2 * @file llinventorymodel.h
3 * @brief LLInventoryModel class header file
4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LL_LLINVENTORYMODEL_H
29#define LL_LLINVENTORYMODEL_H
30
31#include "llassetstorage.h"
32#include "lldarray.h"
33//#include "llskiplist.h"
34//#include "llptrskipmap.h"
35#include "lluuid.h"
36#include "llpermissionsflags.h"
37#include "llstring.h"
38
39#include <map>
40#include <set>
41#include <string>
42#include <vector>
43
44//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45// Class LLInventoryObserver
46//
47// This class is designed to be a simple abstract base class which can
48// relay messages when the inventory changes.
49//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50
51class LLInventoryObserver
52{
53public:
54 // This enumeration is a way to refer to what changed in a more
55 // human readable format. You can mask the value provided by
56 // chaged() to see if the observer is interested in the change.
57 enum
58 {
59 NONE = 0,
60 LABEL = 1, // name changed
61 INTERNAL = 2, // internal change, eg, asset uuid different
62 ADD = 4, // something added
63 REMOVE = 8, // something deleted
64 STRUCTURE = 16, // structural change, eg, item or folder moved
65 CALLING_CARD = 32, // online, grant status, cancel, etc change
66 ALL = 0xffffffff
67 };
68 virtual ~LLInventoryObserver() {};
69 virtual void changed(U32 mask) = 0;
70};
71
72//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73// Class LLInventoryModel
74//
75// This class represents a collection of inventory, and provides
76// efficient ways to access that information. This class could in
77// theory be used for any place where you need inventory, though it
78// optimizes for time efficiency - not space efficiency, probably
79// making it inappropriate for use on tasks.
80//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81
82
83class LLInventoryObject;
84class LLInventoryItem;
85class LLInventoryCategory;
86class LLViewerInventoryItem;
87class LLViewerInventoryCategory;
88class LLViewerInventoryItem;
89class LLViewerInventoryCategory;
90class LLMessageSystem;
91class LLInventoryCollectFunctor;
92
93class LLInventoryModel
94{
95public:
96 typedef enum e_has_children
97 {
98 CHILDREN_NO,
99 CHILDREN_YES,
100 CHILDREN_MAYBE
101 }EHasChildren;
102
103 // These are used a lot...
104 typedef LLDynamicArray<LLPointer<LLViewerInventoryCategory> > cat_array_t;
105 typedef LLDynamicArray<LLPointer<LLViewerInventoryItem> > item_array_t;
106
107 // construction & destruction
108 LLInventoryModel();
109 ~LLInventoryModel();
110
111 //
112 // Accessors
113 //
114
115 // This is a convenience function to check if one object has a
116 // parent chain up to the category specified by UUID.
117 BOOL isObjectDescendentOf(const LLUUID& obj_id, const LLUUID& cat_id);
118
119 // Get the object by id. Returns NULL if not found.
120 // * WARNING: use the pointer returned for read operations - do
121 // not modify the object values in place or you will break stuff.
122 LLInventoryObject* getObject(const LLUUID& id) const;
123
124 // Get the item by id. Returns NULL if not found.
125 // * WARNING: use the pointer for read operations - use the
126 // updateItem() method to actually modify values.
127 LLViewerInventoryItem* getItem(const LLUUID& id) const;
128
129 // Get the category by id. Returns NULL if not found.
130 // * WARNING: use the pointer for read operations - use the
131 // updateCategory() method to actually modify values.
132 LLViewerInventoryCategory* getCategory(const LLUUID& id) const;
133
134 // Return the number of items or categories
135 S32 getItemCount() const;
136 S32 getCategoryCount() const;
137
138 // Return the direct descendents of the id provided.Set passed
139 // in values to NULL if the call fails.
140 // *WARNING: The array provided points straight into the guts of
141 // this object, and should only be used for read operations, since
142 // modifications may invalidate the internal state of the
143 // inventory.
144 void getDirectDescendentsOf(const LLUUID& cat_id,
145 cat_array_t*& categories,
146 item_array_t*& items) const;
147
148 // Starting with the object specified, add it's descendents to the
149 // array provided, but do not add the inventory object specified
150 // by id. There is no guaranteed order. Neither array will be
151 // erased before adding objects to it. Do not store a copy of the
152 // pointers collected - use them, and collect them again later if
153 // you need to reference the same objects.
154 enum { EXCLUDE_TRASH = FALSE, INCLUDE_TRASH = TRUE };
155 void collectDescendents(const LLUUID& id,
156 cat_array_t& categories,
157 item_array_t& items,
158 BOOL include_trash);
159
160 void collectDescendentsIf(const LLUUID& id,
161 cat_array_t& categories,
162 item_array_t& items,
163 BOOL include_trash,
164 LLInventoryCollectFunctor& add);
165
166 //
167 // Mutators
168 //
169
170 // Calling this method with an inventory item will either change
171 // an existing item with a matching item_id, or will add the item
172 // to the current inventory. Returns the change mask generated by
173 // the update. No notifcation will be sent to observers. This
174 // method will only generate network traffic if the item had to be
175 // reparented.
176 // *NOTE: In usage, you will want to perform cache accounting
177 // operations in LLInventoryModel::accountForUpdate() or
178 // LLViewerInventoryItem::updateServer() before calling this
179 // method.
180 U32 updateItem(const LLViewerInventoryItem* item);
181
182 // Calling this method with an inventory category will either
183 // change an existing item with the matching id, or it will add
184 // the category. No notifcation will be sent to observers. This
185 // method will only generate network traffic if the item had to be
186 // reparented.
187 // *NOTE: In usage, you will want to perform cache accounting
188 // operations in LLInventoryModel::accountForUpdate() or
189 // LLViewerInventoryCategory::updateServer() before calling this
190 // method.
191 void updateCategory(const LLViewerInventoryCategory* cat);
192
193 // This method will move the specified object id to the specified
194 // category, update the internal structures. No cache accounting,
195 // observer notification, or server update is performed.
196 void moveObject(const LLUUID& object_id, const LLUUID& cat_id);
197
198 // delete a particular inventory object by ID. This will purge one
199 // object from the internal data structures maintaining a
200 // cosistent internal state. No cache accounting, observer
201 // notification, or server update is performed.
202 void deleteObject(const LLUUID& id);
203
204 // This is a method which collects the descendents of the id
205 // provided. If the category is not found, no action is
206 // taken. This method goes through the long winded process of
207 // removing server representation of folders and items while doing
208 // cache accounting in a fairly efficient manner. This method does
209 // not notify observers (though maybe it shouldd...)
210 void purgeDescendentsOf(const LLUUID& id);
211
212 // This method optimally removes the referenced categories and
213 // items from the current agent's inventory in the database. It
214 // performs all of the during deletion. The local representation
215 // is not removed.
216 void deleteFromServer(LLDynamicArray<LLUUID>& category_ids,
217 LLDynamicArray<LLUUID>& item_ids);
218
219 // Add/remove an observer. If the observer is destroyed, be sure
220 // to remove it.
221 void addObserver(LLInventoryObserver* observer);
222 void removeObserver(LLInventoryObserver* observer);
223
224 //
225 // Misc Methods
226 //
227
228 // findCategoryUUIDForType() returns the uuid of the category that
229 // specifies 'type' as what it defaults to containing. The
230 // category is not necessarily only for that type. *NOTE: This
231 // will create a new inventory category on the fly if one does not
232 // exist.
233 LLUUID findCategoryUUIDForType(LLAssetType::EType preferred_type);
234
235 // Call this method when it's time to update everyone on a new
236 // state, by default, the inventory model will not update
237 // observers automatically.
238 void notifyObservers();
239
240 // This allows outsiders to tell the inventory if something has
241 // been changed 'under the hood', but outside the control of the
242 // inventory. For example, if we grant someone modify permissions,
243 // then that changes the data structures for LLAvatarTracker, but
244 // potentially affects inventory observers. This API makes sure
245 // that the next notify will include that notification.
246 void addChangedMask(U32 mask, const LLUUID& referent);
247
248 const std::set<LLUUID>& getChangedIDs() { return mChangedItemIDs; }
249
250 // This method to prepares a set of mock inventory which provides
251 // minimal functionality before the actual arrival of inventory.
252 //void mock(const LLUUID& root_id);
253
254 // make sure we have the descendents in the structure.
255 void fetchDescendentsOf(const LLUUID& folder_id);
256
257 // call this method to request the inventory.
258 //void requestFromServer(const LLUUID& agent_id);
259
260 // call this method on logout to save a terse representation
261 void cache(const LLUUID& parent_folder_id, const LLUUID& agent_id);
262
263 // Generates a string containing the path to the item specified by
264 // item_id.
265 void appendPath(const LLUUID& id, LLString& path);
266
267 // message handling functionality
268 static void registerCallbacks(LLMessageSystem* msg);
269
270 // Convenience function to create a new category. You could call
271 // updateCatgory() with a newly generated UUID category, but this
272 // version will take care of details like what the name should be
273 // based on preferred type. Returns the UUID of the new
274 // category. If you want to use the default name based on type,
275 // pass in a NULL to the 'name parameter.
276 LLUUID createNewCategory(const LLUUID& parent_id,
277 LLAssetType::EType preferred_type,
278 const LLString& name);
279
280 // methods to load up inventory skeleton & meat. These are used
281 // during authentication. return true if everything parsed.
282 typedef std::map<std::string, std::string> response_t;
283 typedef std::vector<response_t> options_t;
284 bool loadSkeleton(const options_t& options, const LLUUID& owner_id);
285 bool loadMeat(const options_t& options, const LLUUID& owner_id);
286
287 // This is a brute force method to rebuild the entire parent-child
288 // relations.
289 void buildParentChildMap();
290
291 //
292 // Category accounting.
293 //
294
295 // This structure represents the number of items added or removed
296 // from a category.
297 struct LLCategoryUpdate
298 {
299 LLCategoryUpdate() : mDescendentDelta(0) {}
300 LLCategoryUpdate(const LLUUID& category_id, S32 delta) :
301 mCategoryID(category_id),
302 mDescendentDelta(delta) {}
303 LLUUID mCategoryID;
304 S32 mDescendentDelta;
305 };
306 typedef std::vector<LLCategoryUpdate> update_list_t;
307
308 // This structure eixts to make it easier to account for deltas in
309 // a map.
310 struct LLInitializedS32
311 {
312 LLInitializedS32() : mValue(0) {}
313 LLInitializedS32(S32 value) : mValue(value) {}
314 S32 mValue;
315 LLInitializedS32& operator++() { ++mValue; return *this; }
316 LLInitializedS32& operator--() { --mValue; return *this; }
317 };
318 typedef std::map<LLUUID, LLInitializedS32> update_map_t;
319
320 // Call these methods when there are category updates, but call
321 // them *before* the actual update so the method can do descendent
322 // accounting correctly.
323 void accountForUpdate(const LLCategoryUpdate& update);
324 void accountForUpdate(const update_list_t& updates);
325 void accountForUpdate(const update_map_t& updates);
326
327 // Return child status of category children. yes/no/maybe
328 EHasChildren categoryHasChildren(const LLUUID& cat_id) const;
329
330 // returns true iff category version is known and theoretical
331 // descendents == actual descendents.
332 bool isCategoryComplete(const LLUUID& cat_id) const;
333
334 // start and stop background breadth-first fetching of inventory contents
335 // this gets triggered when performing a filter-search
336 static void startBackgroundFetch(const LLUUID& cat_id = LLUUID::null); // start fetch process
337 static void stopBackgroundFetch(); // stop fetch process
338 static BOOL backgroundFetchActive();
339 static bool isEverythingFetched();
340 static void backgroundFetch(void*); // background fetch idle function
341
342protected:
343
344 // Internal methods which add inventory and make sure that all of
345 // the internal data structures are consistent. These methods
346 // should be passed pointers of newly created objects, and the
347 // instance will take over the memory management from there.
348 void addCategory(LLViewerInventoryCategory* category);
349 void addItem(LLViewerInventoryItem* item);
350
351 // Internal method which looks for a category with the specified
352 // preferred type. Returns LLUUID::null if not found
353 LLUUID findCatUUID(LLAssetType::EType preferred_type);
354
355 // Empty the entire contents
356 void empty();
357
358 // Given the current state of the inventory items, figure out the
359 // clone information. *FIX: This is sub-optimal, since we can
360 // insert this information snurgically, but this makes sure the
361 // implementation works before we worry about optimization.
362 //void recalculateCloneInformation();
363
364 // file import/export.
365 static bool loadFromFile(
366 const char* filename,
367 cat_array_t& categories,
368 item_array_t& items);
369 static bool saveToFile(
370 const char* filename,
371 const cat_array_t& categories,
372 const item_array_t& items);
373
374 // message handling functionality
375 //static void processUseCachedInventory(LLMessageSystem* msg, void**);
376 static void processUpdateCreateInventoryItem(LLMessageSystem* msg, void**);
377 static void processRemoveInventoryItem(LLMessageSystem* msg, void**);
378 static void processUpdateInventoryFolder(LLMessageSystem* msg, void**);
379 static void processRemoveInventoryFolder(LLMessageSystem* msg, void**);
380 //static void processExchangeCallingcard(LLMessageSystem* msg, void**);
381 //static void processAddCallingcard(LLMessageSystem* msg, void**);
382 //static void processDeclineCallingcard(LLMessageSystem* msg, void**);
383 static void processSaveAssetIntoInventory(LLMessageSystem* msg, void**);
384 static void processBulkUpdateInventory(LLMessageSystem* msg, void**);
385 static void processInventoryDescendents(LLMessageSystem* msg, void**);
386 static void processMoveInventoryItem(LLMessageSystem* msg, void**);
387 static void processFetchInventoryReply(LLMessageSystem* msg, void**);
388
389 bool messageUpdateCore(LLMessageSystem* msg, bool do_accounting, bool highlight_new);
390
391protected:
392 // Varaibles used to track what has changed since the last notify.
393 U32 mModifyMask;
394 typedef std::set<LLUUID> changed_items_t;
395 changed_items_t mChangedItemIDs;
396
397 // Information for tracking the actual inventory. We index this
398 // information in a lot of different ways so we can access
399 // the inventory using several different identifiers.
400 // mInventory member data is the 'master' list of inventory, and
401 // mCategoryMap and mItemMap store uuid->object mappings.
402 typedef std::map<LLUUID, LLPointer<LLViewerInventoryCategory> > cat_map_t;
403 typedef std::map<LLUUID, LLPointer<LLViewerInventoryItem> > item_map_t;
404 //inv_map_t mInventory;
405 cat_map_t mCategoryMap;
406 item_map_t mItemMap;
407
408 // cache recent lookups
409 mutable LLPointer<LLViewerInventoryItem> mLastItem;
410
411 // This last set of indices is used to map parents to children.
412 //LLPtrSkipMap<const LLUUID, cat_array_t*> mParentChildCategoryTree;
413 //LLPtrSkipMap<const LLUUID, item_array_t*> mParentChildItemTree;
414 typedef std::map<LLUUID, cat_array_t*> parent_cat_map_t;
415 typedef std::map<LLUUID, item_array_t*> parent_item_map_t;
416 parent_cat_map_t mParentChildCategoryTree;
417 parent_item_map_t mParentChildItemTree;
418
419 typedef std::set<LLInventoryObserver*> observer_list_t;
420 observer_list_t mObservers;
421
422 // completing the fetch once per session should be sufficient
423 static BOOL sBackgroundFetchActive;
424 static BOOL sTimelyFetchPending;
425 static BOOL sAllFoldersFetched;
426 static BOOL sFullFetchStarted;
427 static S32 sNumFetchRetries;
428 static LLFrameTimer sFetchTimer;
429 static F32 sMinTimeBetweenFetches;
430 static F32 sMaxTimeBetweenFetches;
431
432public:
433 // *NOTE: DEBUG functionality
434 void dumpInventory();
435};
436
437// a special inventory model for the agent
438extern LLInventoryModel gInventory;
439
440//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
441// Class LLInventoryCollectFunctor
442//
443// Base class for LLInventoryModel::collectDescendentsIf() method
444// which accepts an instance of one of these objects to use as the
445// function to determine if it should be added. Derive from this class
446// and override the () operator to return TRUE if you want to collect
447// the category or item passed in.
448//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
449
450class LLInventoryCollectFunctor
451{
452public:
453 virtual ~LLInventoryCollectFunctor(){};
454 virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item) = 0;
455};
456
457
458//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
459// Class LLAssetIDMatches
460//
461// This functor finds inventory items pointing to the specified asset
462//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
463class LLViewerInventoryItem;
464
465class LLAssetIDMatches : public LLInventoryCollectFunctor
466{
467public:
468 LLAssetIDMatches(const LLUUID& asset_id) : mAssetID(asset_id) {}
469 virtual ~LLAssetIDMatches() {}
470 bool operator()(LLInventoryCategory* cat, LLInventoryItem* item);
471
472protected:
473 LLUUID mAssetID;
474};
475
476
477//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
478// Class LLIsType
479//
480// Implementation of a LLInventoryCollectFunctor which returns TRUE if
481// the type is the type passed in during construction.
482//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
483
484class LLIsType : public LLInventoryCollectFunctor
485{
486public:
487 LLIsType(LLAssetType::EType type) : mType(type) {}
488 virtual ~LLIsType() {}
489 virtual bool operator()(LLInventoryCategory* cat,
490 LLInventoryItem* item);
491protected:
492 LLAssetType::EType mType;
493};
494
495
496//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
497// Class LLIsNotType
498//
499// Implementation of a LLInventoryCollectFunctor which returns FALSE if the
500// type is the type passed in during construction, otherwise false.
501//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
502
503class LLIsNotType : public LLInventoryCollectFunctor
504{
505public:
506 LLIsNotType(LLAssetType::EType type) : mType(type) {}
507 virtual ~LLIsNotType() {}
508 virtual bool operator()(LLInventoryCategory* cat,
509 LLInventoryItem* item);
510protected:
511 LLAssetType::EType mType;
512};
513
514class LLIsTypeWithPermissions : public LLInventoryCollectFunctor
515{
516public:
517 LLIsTypeWithPermissions(LLAssetType::EType type, const PermissionBit perms, const LLUUID &agent_id, const LLUUID &group_id)
518 : mType(type), mPerm(perms), mAgentID(agent_id), mGroupID(group_id) {}
519 virtual ~LLIsTypeWithPermissions() {}
520 virtual bool operator()(LLInventoryCategory* cat,
521 LLInventoryItem* item);
522protected:
523 LLAssetType::EType mType;
524 PermissionBit mPerm;
525 LLUUID mAgentID;
526 LLUUID mGroupID;
527};
528
529//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
530// Class LLIsClone
531//
532// Implementation of a LLInventoryCollectFunctor which returns TRUE if
533// the object is a clone of the item passed in during
534// construction.
535//
536// *NOTE: Since clone information is determined based off of asset id
537// (or creator with calling cards), if the id is NULL, it has no
538// clones - even itself.
539//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
540
541//class LLIsClone : public LLInventoryCollectFunctor
542//{
543//public:
544// LLIsClone(LLViewerInventoryItem* item) : mItem(item) {}
545// virtual ~LLIsClone() {}
546// virtual bool operator()(LLViewerInventoryCategory* cat,
547// LLViewerInventoryItem* item);
548//protected:
549// LLPointer<LLViewerInventoryItem> mItem;
550//};
551
552//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
553// Class LLBuddyCollector
554//
555// Simple class that collects calling cards that are not null, and not
556// the agent. Duplicates are possible.
557//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
558
559class LLBuddyCollector : public LLInventoryCollectFunctor
560{
561public:
562 LLBuddyCollector() {}
563 virtual ~LLBuddyCollector() {}
564 virtual bool operator()(LLInventoryCategory* cat,
565 LLInventoryItem* item);
566};
567
568//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
569// Class LLUniqueBuddyCollector
570//
571// Simple class that collects calling cards that are not null, and not
572// the agent. Duplicates are discarded.
573//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
574
575class LLUniqueBuddyCollector : public LLInventoryCollectFunctor
576{
577public:
578 LLUniqueBuddyCollector() {}
579 virtual ~LLUniqueBuddyCollector() {}
580 virtual bool operator()(LLInventoryCategory* cat,
581 LLInventoryItem* item);
582
583protected:
584 std::set<LLUUID> mSeen;
585};
586
587//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
588// Class LLParticularBuddyCollector
589//
590// Simple class that collects calling cards that match a particular uuid
591//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
592
593class LLParticularBuddyCollector : public LLInventoryCollectFunctor
594{
595public:
596 LLParticularBuddyCollector(const LLUUID& id) : mBuddyID(id) {}
597 virtual ~LLParticularBuddyCollector() {}
598 virtual bool operator()(LLInventoryCategory* cat,
599 LLInventoryItem* item);
600protected:
601 LLUUID mBuddyID;
602};
603
604
605//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
606// Class LLNameCategoryCollector
607//
608// Collects categories based on case-insensitive match of prefix
609//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
610
611class LLNameCategoryCollector : public LLInventoryCollectFunctor
612{
613public:
614 LLNameCategoryCollector(const char* name) : mName(name) {}
615 virtual ~LLNameCategoryCollector() {}
616 virtual bool operator()(LLInventoryCategory* cat,
617 LLInventoryItem* item);
618protected:
619 std::string mName;
620};
621
622
623//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
624// Class LLInventoryCompletionObserver
625//
626// Class which can be used as a base class for doing something when
627// when all observed items are locally complete. This class implements
628// the changed() method of LLInventoryObserver and declares a new
629// method named done() which is called when all watched items have
630// complete information in the inventory model.
631//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
632
633class LLInventoryCompletionObserver : public LLInventoryObserver
634{
635public:
636 LLInventoryCompletionObserver() {}
637 virtual void changed(U32 mask);
638
639 void watchItem(const LLUUID& id);
640
641protected:
642 virtual void done() = 0;
643
644 typedef std::vector<LLUUID> item_ref_t;
645 item_ref_t mComplete;
646 item_ref_t mIncomplete;
647};
648
649
650//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
651// Class LLInventoryFetchObserver
652//
653// This class is much like the LLInventoryCompletionObserver, except
654// that it handles all the the fetching necessary. Override the done()
655// method to do the thing you want.
656//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
657
658class LLInventoryFetchObserver : public LLInventoryObserver
659{
660public:
661 LLInventoryFetchObserver() {}
662 virtual void changed(U32 mask);
663
664 typedef std::vector<LLUUID> item_ref_t;
665
666 bool isEverythingComplete() const;
667 void fetchItems(const item_ref_t& ids);
668 virtual void done() = 0;
669
670protected:
671 item_ref_t mComplete;
672 item_ref_t mIncomplete;
673};
674
675//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
676// Class LLInventoryFetchDescendentsObserver
677//
678// This class is much like the LLInventoryCompletionObserver, except
679// that it handles fetching based on category. Override the done()
680// method to do the thing you want.
681//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
682class LLInventoryFetchDescendentsObserver : public LLInventoryObserver
683{
684public:
685 LLInventoryFetchDescendentsObserver() {}
686 virtual void changed(U32 mask);
687
688 typedef std::vector<LLUUID> folder_ref_t;
689 void fetchDescendents(const folder_ref_t& ids);
690 bool isEverythingComplete() const;
691 virtual void done() = 0;
692
693protected:
694 bool isComplete(LLViewerInventoryCategory* cat);
695 folder_ref_t mIncompleteFolders;
696 folder_ref_t mCompleteFolders;
697};
698
699//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
700// Class LLInventoryFetchComboObserver
701//
702// This class does an appropriate combination of fetch descendents and
703// item fetches based on completion of categories and items. Much like
704// the fetch and fetch descendents, this will call done() when everything
705// has arrived.
706//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
707class LLInventoryFetchComboObserver : public LLInventoryObserver
708{
709public:
710 LLInventoryFetchComboObserver() : mDone(false) {}
711 virtual void changed(U32 mask);
712
713 typedef std::vector<LLUUID> folder_ref_t;
714 typedef std::vector<LLUUID> item_ref_t;
715 void fetch(const folder_ref_t& folder_ids, const item_ref_t& item_ids);
716
717 virtual void done() = 0;
718
719protected:
720 bool mDone;
721 folder_ref_t mCompleteFolders;
722 folder_ref_t mIncompleteFolders;
723 item_ref_t mCompleteItems;
724 item_ref_t mIncompleteItems;
725};
726
727//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
728// Class LLInventoryExistenceObserver
729//
730// This class is used as a base class for doing somethign when all the
731// observed item ids exist in the inventory somewhere. You can derive
732// a class from this class and implement the done() method to do
733// something useful.
734//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
735
736class LLInventoryExistenceObserver : public LLInventoryObserver
737{
738public:
739 LLInventoryExistenceObserver() {}
740 virtual void changed(U32 mask);
741
742 void watchItem(const LLUUID& id);
743
744protected:
745 virtual void done() = 0;
746
747 typedef std::vector<LLUUID> item_ref_t;
748 item_ref_t mExist;
749 item_ref_t mMIA;
750};
751
752//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
753// Class LLInventoryTransactionObserver
754//
755// Class which can be used as a base class for doing something when an
756// inventory transaction completes.
757//
758// *NOTE: This class is not quite complete. Avoid using unless you fix up it's
759// functionality gaps.
760//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
761
762class LLInventoryTransactionObserver : public LLInventoryObserver
763{
764public:
765 LLInventoryTransactionObserver(const LLTransactionID& transaction_id);
766 virtual void changed(U32 mask);
767
768protected:
769 typedef std::vector<LLUUID> folder_ref_t;
770 typedef std::vector<LLUUID> item_ref_t;
771 virtual void done(const folder_ref_t& folders, const item_ref_t& items) = 0;
772
773 LLTransactionID mTransactionID;
774};
775
776
777#endif // LL_LLINVENTORYMODEL_H