SmartFoxServer 2X C++ API
SFSUser.h
1 // ===================================================================
2 //
3 // Description
4 // Contains the definition of SFSUser
5 //
6 // Revision history
7 // Date Description
8 // 30-Nov-2012 First version
9 //
10 // ===================================================================
11 #ifndef __SFSUser__
12 #define __SFSUser__
13 
14 #include "User.h"
15 #include "Data/Vec3D.h"
16 
17 #include <boost/shared_ptr.hpp> // Boost Asio shared pointer
18 #include <boost/enable_shared_from_this.hpp> // Boost shared_ptr for this
19 
20 #if defined(_MSC_VER)
21 #pragma warning(disable:4786) // STL library: disable warning 4786; this warning is generated due to a Microsoft bug
22 #endif
23 #include <string> // STL library: string object
24 #include <list> // STL library: list object
25 #include <vector> // STL library: vector object
26 #include <map> // STL library: map object
27 using namespace std; // STL library: declare the STL namespace
28 
29 using namespace Sfs2X::Entities::Data;
30 using namespace Sfs2X::Entities::Managers;
31 using namespace Sfs2X::Entities::Variables;
32 using namespace Sfs2X::Exceptions;
33 
34 namespace Sfs2X {
35 namespace Entities {
36 
45  class DLLImportExport SFSUser : public User, public boost::enable_shared_from_this<SFSUser>
46  {
47  public:
48 
49  // -------------------------------------------------------------------
50  // Public methods
51  // -------------------------------------------------------------------
52 
53  static boost::shared_ptr<User> FromSFSArray(boost::shared_ptr<ISFSArray> sfsa, boost::shared_ptr<Room> room);
54  static boost::shared_ptr<User> FromSFSArray(boost::shared_ptr<ISFSArray> sfsa);
55 
56  SFSUser(long int id, string name);
57  SFSUser(long int id, string name, bool isItMe);
58  virtual ~SFSUser();
59 
63  long int Id();
64 
68  boost::shared_ptr<string> Name();
69 
84  long int PlayerId();
85 
93  bool IsPlayer();
94 
102  bool IsSpectator();
103 
117  long int GetPlayerId (boost::shared_ptr<Room> room);
118 
119  void SetPlayerId(long int id, boost::shared_ptr<Room> room);
120 
121  void RemovePlayerId(boost::shared_ptr<Room> room);
122 
127  long int PrivilegeId();
128 
133  void PrivilegeId(long int value);
134 
139  boost::shared_ptr<IUserManager> UserManager();
140 
145  void UserManager(boost::shared_ptr<IUserManager> value);
146 
148  boost::shared_ptr<Vec3D> AOIEntryPoint();
149 
151  void AOIEntryPoint(boost::shared_ptr<Vec3D> value);
152 
153  //--------------------------------------------------
154 
161  bool IsGuest();
162 
169  bool IsStandardUser();
170 
177  bool IsModerator();
178 
185  bool IsAdmin();
186 
196  bool IsPlayerInRoom(boost::shared_ptr<Room> room);
197 
207  bool IsSpectatorInRoom(boost::shared_ptr<Room> room);
208 
218  bool IsJoinedInRoom(boost::shared_ptr<Room> room);
219 
223  bool IsItMe();
224 
232  boost::shared_ptr<vector<boost::shared_ptr<UserVariable> > > GetVariables();
233 
244  boost::shared_ptr<UserVariable> GetVariable(string varName);
245 
246  void SetVariable(boost::shared_ptr<UserVariable> userVariable);
247 
248  virtual void SetVariables(boost::shared_ptr<vector<boost::shared_ptr<UserVariable> > > userVaribles);
249 
260  bool ContainsVariable(string name);
261 
268  boost::shared_ptr<map<string, boost::shared_ptr<void> > > Properties();
269 
276  void Properties(boost::shared_ptr<map<string, boost::shared_ptr<void> > > value);
277 
278  boost::shared_ptr<string> ToString();
279 
280  // -------------------------------------------------------------------
281  // Public members
282  // -------------------------------------------------------------------
283 
284  protected:
285 
286  // -------------------------------------------------------------------
287  // Protected methods
288  // -------------------------------------------------------------------
289 
290  // -------------------------------------------------------------------
291  // Protected members
292  // -------------------------------------------------------------------
293 
294  long int id;
295  long int privilegeId;
296  boost::shared_ptr<string> name;
297  bool isItMe;
298  boost::shared_ptr<map<string, boost::shared_ptr<UserVariable> > > variables;
299  boost::shared_ptr<map<string, boost::shared_ptr<void> > > properties;
300  bool isModerator;
301  boost::shared_ptr<map<long int, long int> > playerIdByRoomId;
302  boost::shared_ptr<IUserManager> userManager;
303  boost::shared_ptr<Vec3D> aoiEntryPoint;
304 
305  private:
306 
307  // -------------------------------------------------------------------
308  // Private methods
309  // -------------------------------------------------------------------
310 
311  void Init(long int id, string name, bool isItMe);
312  void RemoveUserVariable(string varName);
313 
314  // -------------------------------------------------------------------
315  // Private members
316  // -------------------------------------------------------------------
317  };
318 
319 } // namespace Entities
320 } // namespace Sfs2X
321 
322 #endif
Definition: SFSCodecError.cpp:14
STL namespace.
Definition: IBuddyManager.h:32
The User object represent a client logged in the Server.
Definition: SFSUser.h:45
The User interface defines all the methods and properties that an object representing a SmartFoxServe...
Definition: User.h:55
Definition: BaseVariable.cpp:15
Definition: SmartFox.cpp:24
Definition: ISFSArray.h:17