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