llpathfindingobjectlist.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**
  2. * @file llpathfindingobjectlist.cpp
  3. * @brief Implementation of llpathfindingobjectlist
  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. #include "llviewerprecompiledheaders.h"
  33. #include "llpathfindingobjectlist.h"
  34. #include "llpathfindingobject.h"
  35. LLPathfindingObjectList::LLPathfindingObjectList()
  36. {
  37. }
  38. LLPathfindingObjectList::~LLPathfindingObjectList()
  39. {
  40. clear();
  41. }
  42. void LLPathfindingObjectList::clear()
  43. {
  44. for (LLPathfindingObject::map_t::iterator it = mObjectMap.begin(),
  45. end = mObjectMap.end();
  46. it != end; ++it)
  47. {
  48. it->second.reset();
  49. }
  50. mObjectMap.clear();
  51. }
  52. LLPathfindingObject::ptr_t LLPathfindingObjectList::find(const LLUUID& obj_id) const
  53. {
  54. LLPathfindingObject::ptr_t objectp;
  55. LLPathfindingObject::map_t::const_iterator it = mObjectMap.find(obj_id);
  56. if (it != mObjectMap.end())
  57. {
  58. objectp = it->second;
  59. }
  60. return objectp;
  61. }
  62. void LLPathfindingObjectList::update(LLPathfindingObject::ptr_t objectp)
  63. {
  64. if (!objectp) return;
  65. const LLUUID& object_id = objectp->getUUID();
  66. LLPathfindingObject::map_t::iterator it = mObjectMap.find(object_id);
  67. if (it == mObjectMap.end())
  68. {
  69. mObjectMap.emplace(object_id, objectp);
  70. }
  71. else
  72. {
  73. it->second = objectp;
  74. }
  75. }
  76. void LLPathfindingObjectList::update(ptr_t object_listp)
  77. {
  78. if (object_listp && !object_listp->isEmpty())
  79. {
  80. for (const_iterator it = object_listp->begin();
  81. it != object_listp->end(); ++it)
  82. {
  83. LLPathfindingObject::ptr_t objectp = it->second;
  84. update(objectp);
  85. }
  86. }
  87. }