PageRenderTime 33ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llinventory/lllandmark.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 108 lines | 48 code | 20 blank | 40 comment | 0 complexity | 7588c553ec138306676db1dcb7cc5c7e MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lllandmark.h
  3. * @brief Landmark asset class
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLLANDMARK_H
  27. #define LL_LLLANDMARK_H
  28. #include <map>
  29. #include <boost/function.hpp>
  30. #include "llframetimer.h"
  31. #include "lluuid.h"
  32. #include "v3dmath.h"
  33. class LLMessageSystem;
  34. class LLHost;
  35. class LLLandmark
  36. {
  37. public:
  38. // for calling back interested parties when a region handle comes back.
  39. typedef boost::function<void(const LLUUID& region_id, const U64& region_handle)> region_handle_callback_t;
  40. ~LLLandmark() {}
  41. // returns true if the position is known.
  42. bool getGlobalPos(LLVector3d& pos);
  43. // setter used in conjunction if more information needs to be
  44. // collected from the server.
  45. void setGlobalPos(const LLVector3d& pos);
  46. // return true if the region is known
  47. bool getRegionID(LLUUID& region_id);
  48. // return the local coordinates if known
  49. LLVector3 getRegionPos() const;
  50. // constructs a new LLLandmark from a string
  51. // return NULL if there's an error
  52. static LLLandmark* constructFromString(const char *buffer);
  53. // register callbacks that this class handles
  54. static void registerCallbacks(LLMessageSystem* msg);
  55. // request information about region_id to region_handle.Pass in a
  56. // callback pointer which will be erase but NOT deleted after the
  57. // callback is made. This function may call into the message
  58. // system to get the information.
  59. static void requestRegionHandle(
  60. LLMessageSystem* msg,
  61. const LLHost& upstream_host,
  62. const LLUUID& region_id,
  63. region_handle_callback_t callback);
  64. // Call this method to create a lookup for this region. This
  65. // simplifies a lot of the code.
  66. static void setRegionHandle(const LLUUID& region_id, U64 region_handle);
  67. private:
  68. LLLandmark();
  69. LLLandmark(const LLVector3d& pos);
  70. static void processRegionIDAndHandle(LLMessageSystem* msg, void**);
  71. static void expireOldEntries();
  72. private:
  73. LLUUID mRegionID;
  74. LLVector3 mRegionPos;
  75. bool mGlobalPositionKnown;
  76. LLVector3d mGlobalPos;
  77. struct CacheInfo
  78. {
  79. U64 mRegionHandle;
  80. LLFrameTimer mTimer;
  81. };
  82. static std::pair<LLUUID, U64> mLocalRegion;
  83. typedef std::map<LLUUID, CacheInfo> region_map_t;
  84. static region_map_t mRegions;
  85. typedef std::multimap<LLUUID, region_handle_callback_t> region_callback_map_t;
  86. static region_callback_map_t sRegionCallbackMap;
  87. };
  88. #endif