llpathfindingobject.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /**
  2. * @file llpathfindingobject.h
  3. * @brief LLPathfindingObject class declaration
  4. *
  5. * $LicenseInfo:firstyear=2012&license=viewergpl$
  6. *
  7. * Copyright (c) 2012, 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. #ifndef LL_LLPATHFINDINGOBJECT_H
  33. #define LL_LLPATHFINDINGOBJECT_H
  34. #include <memory>
  35. #include "boost/function.hpp"
  36. #include "boost/signals2.hpp"
  37. #include "llavatarnamecache.h"
  38. #include "hbfastmap.h"
  39. #include "lluuid.h"
  40. #include "llvector3.h"
  41. class LLPathfindingCharacter;
  42. class LLPathfindingLinkset;
  43. class LLSD;
  44. class LLPathfindingObject
  45. {
  46. protected:
  47. LOG_CLASS(LLPathfindingObject);
  48. public:
  49. typedef std::shared_ptr<LLPathfindingObject> ptr_t;
  50. typedef fast_hmap<LLUUID, ptr_t> map_t;
  51. LLPathfindingObject();
  52. LLPathfindingObject(const LLUUID& id, const LLSD& obj_data);
  53. LLPathfindingObject(const LLPathfindingObject& obj);
  54. virtual ~LLPathfindingObject();
  55. LLPathfindingObject& operator=(const LLPathfindingObject& obj);
  56. LL_INLINE virtual LLPathfindingLinkset* asLinkset()
  57. {
  58. return NULL;
  59. }
  60. LL_INLINE virtual const LLPathfindingLinkset* asLinkset() const
  61. {
  62. return NULL;
  63. }
  64. LL_INLINE virtual LLPathfindingCharacter* asCharacter()
  65. {
  66. return NULL;
  67. }
  68. LL_INLINE virtual const LLPathfindingCharacter* asCharacter() const
  69. {
  70. return NULL;
  71. }
  72. LL_INLINE const LLUUID& getUUID() const { return mUUID; }
  73. LL_INLINE const std::string& getName() const { return mName; }
  74. LL_INLINE const std::string& getDescription() const { return mDescription; }
  75. LL_INLINE bool hasOwner() const { return mOwnerUUID.notNull(); }
  76. LL_INLINE bool hasOwnerName() const { return mHasOwnerName; }
  77. std::string getOwnerName() const;
  78. LL_INLINE bool isGroupOwned() const { return mIsGroupOwned; }
  79. LL_INLINE const LLVector3& getLocation() const { return mLocation; }
  80. typedef boost::function<void(const LLPathfindingObject*)> name_callback_t;
  81. typedef boost::signals2::signal<void(const LLPathfindingObject*)> name_signal_t;
  82. typedef boost::signals2::connection name_connection_t;
  83. name_connection_t registerOwnerNameListener(name_callback_t callback);
  84. private:
  85. void parseObjectData(const LLSD& obj_data);
  86. void fetchOwnerName();
  87. static void handleGroupNameFetch(const LLUUID& group_id,
  88. const std::string& name, bool is_group,
  89. LLPathfindingObject* self);
  90. void handleAvatarNameFetch(const LLUUID& av_id,
  91. const LLAvatarName& av_name);
  92. void disconnectAvatarNameCacheConnection();
  93. private:
  94. LLVector3 mLocation;
  95. LLUUID mUUID;
  96. LLUUID mOwnerUUID;
  97. LLAvatarName mOwnerName;
  98. LLAvatarNameCache::callback_connection_t mAvatarNameCacheConnection;
  99. name_signal_t mOwnerNameSignal;
  100. bool mIsGroupOwned;
  101. bool mHasOwnerName;
  102. std::string mName;
  103. std::string mDescription;
  104. std::string mGroupName;
  105. static uuid_list_t sPendingGroupUUIDs;
  106. typedef fast_hset<LLPathfindingObject*> pathfinding_obj_list_t;
  107. static pathfinding_obj_list_t sGroupQueriesList;
  108. };
  109. #endif // LL_LLPATHFINDINGOBJECT_H