PageRenderTime 36ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llinventory/lluserrelations.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 112 lines | 55 code | 15 blank | 42 comment | 2 complexity | a4fb8b26af8804d71466dbaa8840df4d MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lluserrelations.cpp
  3. * @author Phoenix
  4. * @date 2006-10-12
  5. * @brief Implementation of a simple cache of user relations.
  6. *
  7. * $LicenseInfo:firstyear=2006&license=viewerlgpl$
  8. * Second Life Viewer Source Code
  9. * Copyright (C) 2010, Linden Research, Inc.
  10. *
  11. * This library is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation;
  14. * version 2.1 of the License only.
  15. *
  16. * This library is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with this library; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  26. * $/LicenseInfo$
  27. */
  28. #include "linden_common.h"
  29. #include "lluserrelations.h"
  30. // static
  31. const U8 LLRelationship::GRANTED_VISIBLE_MASK = LLRelationship::GRANT_MODIFY_OBJECTS | LLRelationship::GRANT_MAP_LOCATION;
  32. const LLRelationship LLRelationship::DEFAULT_RELATIONSHIP = LLRelationship(GRANT_ONLINE_STATUS, GRANT_ONLINE_STATUS, false);
  33. LLRelationship::LLRelationship() :
  34. mGrantToAgent(0),
  35. mGrantFromAgent(0),
  36. mChangeSerialNum(0),
  37. mIsOnline(false)
  38. {
  39. }
  40. LLRelationship::LLRelationship(S32 grant_to, S32 grant_from, bool is_online) :
  41. mGrantToAgent(grant_to),
  42. mGrantFromAgent(grant_from),
  43. mChangeSerialNum(0),
  44. mIsOnline(is_online)
  45. {
  46. }
  47. bool LLRelationship::isOnline() const
  48. {
  49. return mIsOnline;
  50. }
  51. void LLRelationship::online(bool is_online)
  52. {
  53. mIsOnline = is_online;
  54. mChangeSerialNum++;
  55. }
  56. bool LLRelationship::isRightGrantedTo(S32 rights) const
  57. {
  58. return ((mGrantToAgent & rights) == rights);
  59. }
  60. bool LLRelationship::isRightGrantedFrom(S32 rights) const
  61. {
  62. return ((mGrantFromAgent & rights) == rights);
  63. }
  64. S32 LLRelationship::getRightsGrantedTo() const
  65. {
  66. return mGrantToAgent;
  67. }
  68. S32 LLRelationship::getRightsGrantedFrom() const
  69. {
  70. return mGrantFromAgent;
  71. }
  72. void LLRelationship::grantRights(S32 to_agent, S32 from_agent)
  73. {
  74. mGrantToAgent |= to_agent;
  75. mGrantFromAgent |= from_agent;
  76. mChangeSerialNum++;
  77. }
  78. void LLRelationship::revokeRights(S32 to_agent, S32 from_agent)
  79. {
  80. mGrantToAgent &= ~to_agent;
  81. mGrantFromAgent &= ~from_agent;
  82. mChangeSerialNum++;
  83. }
  84. /*
  85. bool LLGrantedRights::getNextRights(
  86. LLUUID& agent_id,
  87. S32& to_agent,
  88. S32& from_agent) const
  89. {
  90. rights_map_t::const_iterator iter = mRights.upper_bound(agent_id);
  91. if(iter == mRights.end()) return false;
  92. agent_id = (*iter).first;
  93. to_agent = (*iter).second.mToAgent;
  94. from_agent = (*iter).second.mFromAgent;
  95. return true;
  96. }
  97. */