PageRenderTime 35ms CodeModel.GetById 30ms app.highlight 3ms RepoModel.GetById 1ms 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
  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
 27
 28#ifndef LL_LLLANDMARK_H
 29#define LL_LLLANDMARK_H
 30
 31#include <map>
 32#include <boost/function.hpp>
 33#include "llframetimer.h"
 34#include "lluuid.h"
 35#include "v3dmath.h"
 36
 37class LLMessageSystem;
 38class LLHost;
 39
 40class LLLandmark
 41{
 42public:
 43	// for calling back interested parties when a region handle comes back.
 44	typedef boost::function<void(const LLUUID& region_id, const U64& region_handle)> region_handle_callback_t;
 45
 46	~LLLandmark() {}
 47
 48	// returns true if the position is known.
 49	bool getGlobalPos(LLVector3d& pos);
 50
 51	// setter used in conjunction if more information needs to be
 52	// collected from the server.
 53	void setGlobalPos(const LLVector3d& pos);
 54
 55	// return true if the region is known
 56	bool getRegionID(LLUUID& region_id);
 57
 58	// return the local coordinates if known
 59	LLVector3 getRegionPos() const;
 60
 61	// constructs a new LLLandmark from a string
 62	// return NULL if there's an error
 63	static LLLandmark* constructFromString(const char *buffer);
 64
 65	// register callbacks that this class handles
 66	static void registerCallbacks(LLMessageSystem* msg);
 67
 68	// request information about region_id to region_handle.Pass in a
 69	// callback pointer which will be erase but NOT deleted after the
 70	// callback is made. This function may call into the message
 71	// system to get the information.
 72	static void requestRegionHandle(
 73		LLMessageSystem* msg,
 74		const LLHost& upstream_host,
 75		const LLUUID& region_id,
 76		region_handle_callback_t callback);
 77
 78	// Call this method to create a lookup for this region. This
 79	// simplifies a lot of the code.
 80	static void setRegionHandle(const LLUUID& region_id, U64 region_handle);
 81		
 82private:
 83	LLLandmark();
 84	LLLandmark(const LLVector3d& pos);
 85
 86	static void processRegionIDAndHandle(LLMessageSystem* msg, void**);
 87	static void expireOldEntries();
 88
 89private:
 90	LLUUID mRegionID;
 91	LLVector3 mRegionPos;
 92	bool mGlobalPositionKnown;
 93	LLVector3d mGlobalPos;
 94	
 95	struct CacheInfo
 96	{
 97		U64 mRegionHandle;
 98		LLFrameTimer mTimer;
 99	};
100
101	static std::pair<LLUUID, U64> mLocalRegion;
102	typedef std::map<LLUUID, CacheInfo> region_map_t;
103	static region_map_t mRegions;
104	typedef std::multimap<LLUUID, region_handle_callback_t> region_callback_map_t;
105	static region_callback_map_t sRegionCallbackMap;
106};
107
108#endif