PageRenderTime 26ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llinventory/lluserrelations.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 183 lines | 36 code | 18 blank | 129 comment | 0 complexity | 7f5187b5c1f2d7af5488ea2b4a7178ae MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lluserrelations.h
  3. * @author Phoenix
  4. * @date 2006-10-12
  5. * @brief Declaration of a class for handling granted rights.
  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. #ifndef LL_LLUSERRELAIONS_H
  29. #define LL_LLUSERRELAIONS_H
  30. #include <map>
  31. #include "lluuid.h"
  32. /**
  33. * @class LLRelationship
  34. *
  35. * This class represents a relationship between two agents, where the
  36. * related agent is stored and the other agent is the relationship is
  37. * implicit by container ownership.
  38. * This is merely a cache of this information used by the sim
  39. * and viewer.
  40. *
  41. * You are expected to use this in a map or similar structure, eg:
  42. * typedef std::map<LLUUID, LLRelationship> agent_relationship_map;
  43. */
  44. class LLRelationship
  45. {
  46. public:
  47. /**
  48. * @brief Constructors.
  49. */
  50. LLRelationship();
  51. LLRelationship(S32 grant_to, S32 grant_from, bool is_online);
  52. static const LLRelationship DEFAULT_RELATIONSHIP;
  53. /**
  54. * @name Status functionality
  55. *
  56. * I thought it would be keen to have a generic status interface,
  57. * but the only thing we currently cache is online status. As this
  58. * assumption changes, this API may evolve.
  59. */
  60. //@{
  61. /**
  62. * @brief Does this instance believe the related agent is currently
  63. * online or available.
  64. *
  65. * NOTE: This API may be deprecated if there is any transient status
  66. * other than online status, for example, away/busy/etc.
  67. *
  68. * This call does not check any kind of central store or make any
  69. * deep information calls - it simply checks a cache of online
  70. * status.
  71. * @return Returns true if this relationship believes the agent is
  72. * online.
  73. */
  74. bool isOnline() const;
  75. /**
  76. * @brief Set the online status.
  77. *
  78. * NOTE: This API may be deprecated if there is any transient status
  79. * other than online status.
  80. * @param is_online Se the online status
  81. */
  82. void online(bool is_online);
  83. //@}
  84. /* @name Granted rights
  85. */
  86. //@{
  87. /**
  88. * @brief Anonymous enumeration for specifying rights.
  89. */
  90. enum
  91. {
  92. GRANT_NONE = 0x0,
  93. GRANT_ONLINE_STATUS = 0x1,
  94. GRANT_MAP_LOCATION = 0x2,
  95. GRANT_MODIFY_OBJECTS = 0x4,
  96. };
  97. /**
  98. * ???
  99. */
  100. static const U8 GRANTED_VISIBLE_MASK;
  101. /**
  102. * @brief Check for a set of rights granted to agent.
  103. *
  104. * @param rights A bitfield to check for rights.
  105. * @return Returns true if all rights have been granted.
  106. */
  107. bool isRightGrantedTo(S32 rights) const;
  108. /**
  109. * @brief Check for a set of rights granted from an agent.
  110. *
  111. * @param rights A bitfield to check for rights.
  112. * @return Returns true if all rights have been granted.
  113. */
  114. bool isRightGrantedFrom(S32 rights) const;
  115. /**
  116. * @brief Get the rights granted to the other agent.
  117. *
  118. * @return Returns the bitmask of granted rights.
  119. */
  120. S32 getRightsGrantedTo() const;
  121. /**
  122. * @brief Get the rights granted from the other agent.
  123. *
  124. * @return Returns the bitmask of granted rights.
  125. */
  126. S32 getRightsGrantedFrom() const;
  127. void setRightsTo(S32 to_agent) { mGrantToAgent = to_agent; mChangeSerialNum++; }
  128. void setRightsFrom(S32 from_agent) { mGrantFromAgent = from_agent; mChangeSerialNum++;}
  129. /**
  130. * @brief Get the change count for this agent
  131. *
  132. * Every change to rights will increment the serial number
  133. * allowing listeners to determine when a relationship value is actually new
  134. *
  135. * @return change serial number for relationship
  136. */
  137. S32 getChangeSerialNum() const { return mChangeSerialNum; }
  138. /**
  139. * @brief Grant a set of rights.
  140. *
  141. * Any bit which is set will grant that right if it is set in the
  142. * instance. You can pass in LLGrantedRights::NONE to not change
  143. * that field.
  144. * @param to_agent The rights to grant to agent_id.
  145. * @param from_agent The rights granted from agent_id.
  146. */
  147. void grantRights(S32 to_agent, S32 from_agent);
  148. /**
  149. * @brief Revoke a set of rights.
  150. *
  151. * Any bit which is set will revoke that right if it is set in the
  152. * instance. You can pass in LLGrantedRights::NONE to not change
  153. * that field.
  154. * @param to_agent The rights to grant to agent_id.
  155. * @param from_agent The rights granted from agent_id.
  156. */
  157. void revokeRights(S32 to_agent, S32 from_agent);
  158. //@}
  159. protected:
  160. S32 mGrantToAgent;
  161. S32 mGrantFromAgent;
  162. S32 mChangeSerialNum;
  163. bool mIsOnline;
  164. };
  165. #endif // LL_LLUSERRELAIONS_H