llvoinventorylistener.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**
  2. * @file llvoinventorylistener.h
  3. * @brief Interface for classes that wish to receive updates about viewer object inventory
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. // Description of LLVOInventoryListener class, which is an interface
  33. // for windows that are interested in updates to a ViewerObject's inventory.
  34. #ifndef LL_LLVOINVENTORYLISTENER_H
  35. #define LL_LLVOINVENTORYLISTENER_H
  36. #include "llinventory.h"
  37. class LLViewerObject;
  38. class LLVOInventoryListener
  39. {
  40. public:
  41. virtual void inventoryChanged(LLViewerObject* object,
  42. LLInventoryObject::object_list_t* inventory,
  43. S32 serial_num,
  44. void* user_data) = 0;
  45. // Remove the listener from the object and clear this listener
  46. // When object == NULL, mListenerVObject is used.
  47. void removeVOInventoryListener(LLViewerObject* object = NULL);
  48. // Remove all the listeners from the object and clear them
  49. void removeVOInventoryListeners();
  50. // Just clear this listener, don't worry about the object.
  51. // This assumes mListenerVObjects are clearing their own lists.
  52. // Used only in LLViewerObject::LLInventoryCallbackInfo's destructor.
  53. void clearVOInventoryListener(LLViewerObject* object);
  54. // Did we already register a listener with that object ?
  55. bool hasRegisteredListener(LLViewerObject* object);
  56. // This does the cleaning-up by removing object from all existing
  57. // listeners. This is called by LLViewerObject::markDead()
  58. static void removeObjectFromListeners(LLViewerObject* object);
  59. protected:
  60. LLVOInventoryListener();
  61. virtual ~LLVOInventoryListener();
  62. void registerVOInventoryListener(LLViewerObject* object, void* user_data);
  63. // When object == NULL, mListenerVObject is used.
  64. void requestVOInventory(LLViewerObject* object = NULL);
  65. private:
  66. // LLViewerObject is normally wrapped by an LLPointer, but not in this
  67. // case, because the listeners are cleaned up from an object as soon as it
  68. // is marked dead.
  69. // This holds the last added object (for compatibility with the old
  70. // one-object request per listener interface)
  71. LLViewerObject* mListenerVObject;
  72. // This holds the data for multiple objects.
  73. typedef safe_hset<LLViewerObject*> objects_list_t;
  74. objects_list_t mListenerVObjects;
  75. typedef safe_hset<LLVOInventoryListener*> listeners_list_t;
  76. static listeners_list_t sListeners;
  77. };
  78. #endif