PageRenderTime 21ms CodeModel.GetById 17ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llcommon/llinstancetracker.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 49 lines | 10 code | 3 blank | 36 comment | 0 complexity | 91df98dccf4816ecdc4938248d469bd5 MD5 | raw file
 1/**
 2 * @file   lllinstancetracker.cpp
 3 * 
 4 * $LicenseInfo:firstyear=2009&license=viewerlgpl$
 5 * Second Life Viewer Source Code
 6 * Copyright (C) 2010, Linden Research, Inc.
 7 * 
 8 * This library is free software; you can redistribute it and/or
 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation;
11 * version 2.1 of the License only.
12 * 
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 * Lesser General Public License for more details.
17 * 
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21 * 
22 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
23 * $/LicenseInfo$
24 */
25
26// Precompiled header
27#include "linden_common.h"
28// associated header
29#include "llinstancetracker.h"
30// STL headers
31// std headers
32// external library headers
33// other Linden headers
34
35//static 
36void * & LLInstanceTrackerBase::getInstances(std::type_info const & info)
37{
38	typedef std::map<std::string, void *> InstancesMap;
39	static InstancesMap instances;
40
41	// std::map::insert() is just what we want here. You attempt to insert a
42	// (key, value) pair. If the specified key doesn't yet exist, it inserts
43	// the pair and returns a std::pair of (iterator, true). If the specified
44	// key DOES exist, insert() simply returns (iterator, false). One lookup
45	// handles both cases.
46	return instances.insert(InstancesMap::value_type(info.name(),
47													 InstancesMap::mapped_type()))
48		.first->second;
49}