PageRenderTime 104ms CodeModel.GetById 1ms 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
Possible License(s): LGPL-2.1
  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. // Precompiled header
  26. #include "linden_common.h"
  27. // associated header
  28. #include "llinstancetracker.h"
  29. // STL headers
  30. // std headers
  31. // external library headers
  32. // other Linden headers
  33. //static
  34. void * & LLInstanceTrackerBase::getInstances(std::type_info const & info)
  35. {
  36. typedef std::map<std::string, void *> InstancesMap;
  37. static InstancesMap instances;
  38. // std::map::insert() is just what we want here. You attempt to insert a
  39. // (key, value) pair. If the specified key doesn't yet exist, it inserts
  40. // the pair and returns a std::pair of (iterator, true). If the specified
  41. // key DOES exist, insert() simply returns (iterator, false). One lookup
  42. // handles both cases.
  43. return instances.insert(InstancesMap::value_type(info.name(),
  44. InstancesMap::mapped_type()))
  45. .first->second;
  46. }