00001 00033 #ifndef LL_LLLANDMARK_H 00034 #define LL_LLLANDMARK_H 00035 00036 #include <map> 00037 #include "llframetimer.h" 00038 #include "lluuid.h" 00039 #include "v3dmath.h" 00040 00041 class LLMessageSystem; 00042 class LLHost; 00043 00044 // virutal base class used for calling back interested parties when a 00045 // region handle comes back. 00046 class LLRegionHandleCallback 00047 { 00048 public: 00049 LLRegionHandleCallback() {} 00050 virtual ~LLRegionHandleCallback() {} 00051 virtual bool dataReady( 00052 const LLUUID& region_id, 00053 const U64& region_handle) 00054 { 00055 return true; 00056 } 00057 }; 00058 00059 class LLLandmark 00060 { 00061 public: 00062 ~LLLandmark() {} 00063 00064 // returns true if the position is known. 00065 bool getGlobalPos(LLVector3d& pos); 00066 00067 // setter used in conjunction if more information needs to be 00068 // collected from the server. 00069 void setGlobalPos(const LLVector3d& pos); 00070 00071 // return true if the region is known 00072 bool getRegionID(LLUUID& region_id); 00073 00074 // return the local coordinates if known 00075 LLVector3 getRegionPos() const; 00076 00077 // constructs a new LLLandmark from a string 00078 // return NULL if there's an error 00079 static LLLandmark* constructFromString(const char *buffer); 00080 00081 // register callbacks that this class handles 00082 static void registerCallbacks(LLMessageSystem* msg); 00083 00084 // request information about region_id to region_handle.Pass in a 00085 // callback pointer which will be erase but NOT deleted after the 00086 // callback is made. This function may call into the message 00087 // system to get the information. 00088 static void requestRegionHandle( 00089 LLMessageSystem* msg, 00090 const LLHost& upstream_host, 00091 const LLUUID& region_id, 00092 LLRegionHandleCallback* callback); 00093 00094 // Call this method to create a lookup for this region. This 00095 // simplifies a lot of the code. 00096 static void setRegionHandle(const LLUUID& region_id, U64 region_handle); 00097 00098 private: 00099 LLLandmark(); 00100 LLLandmark(const LLVector3d& pos); 00101 00102 static void processRegionIDAndHandle(LLMessageSystem* msg, void**); 00103 static void expireOldEntries(); 00104 00105 private: 00106 LLUUID mRegionID; 00107 LLVector3 mRegionPos; 00108 bool mGlobalPositionKnown; 00109 LLVector3d mGlobalPos; 00110 00111 struct CacheInfo 00112 { 00113 U64 mRegionHandle; 00114 LLFrameTimer mTimer; 00115 }; 00116 00117 static std::pair<LLUUID, U64> mLocalRegion; 00118 typedef std::map<LLUUID, CacheInfo> region_map_t; 00119 static region_map_t mRegions; 00120 typedef std::multimap<LLUUID, LLRegionHandleCallback*> region_callback_t; 00121 static region_callback_t mRegionCallback; 00122 }; 00123 00124 #endif