SmartFoxServer 2X C++ API
SFSRoom.h
1 // ===================================================================
2 //
3 // Description
4 // Contains the definition of SFSRoom
5 //
6 // Revision history
7 // Date Description
8 // 30-Nov-2012 First version
9 //
10 // ===================================================================
11 #ifndef __SFSRoom__
12 #define __SFSRoom__
13 
14 #include "Data/ISFSArray.h"
15 #include "Room.h"
16 #include "./Managers/IRoomManager.h"
17 
18 #include <boost/shared_ptr.hpp> // Boost Asio shared pointer
19 #include <boost/enable_shared_from_this.hpp> // Boost shared_ptr for this
20 
21 #if defined(_MSC_VER)
22 #pragma warning(disable:4786) // STL library: disable warning 4786; this warning is generated due to a Microsoft bug
23 #endif
24 #include <string> // STL library: string object
25 #include <map> // STL library: map object
26 using namespace std; // STL library: declare the STL namespace
27 
28 using namespace Sfs2X::Entities::Data;
29 using namespace Sfs2X::Entities::Managers;
30 using namespace Sfs2X::Entities::Variables;
31 
32 using namespace Sfs2X::Exceptions;
33 using namespace Sfs2X::Util;
34 
35 namespace Sfs2X {
36 namespace Entities {
37 
56  class DLLImportExport SFSRoom : public Room, public boost::enable_shared_from_this<SFSRoom>
57  {
58  public:
59 
60  // -------------------------------------------------------------------
61  // Public methods
62  // -------------------------------------------------------------------
63 
64  SFSRoom(long int id, string name);
65  SFSRoom(long int id, string name, string groupId);
66  virtual void Dispose();
67  virtual ~SFSRoom();
68  static boost::shared_ptr<Room> FromSFSArray(boost::shared_ptr<ISFSArray> sfsa);
69  long int Id();
70 
74  boost::shared_ptr<string> Name();
75 
79  void Name(string value);
80 
87  boost::shared_ptr<string> GroupId();
88 
92  bool IsGame();
93 
97  void IsGame(bool value);
98 
102  bool IsHidden();
103 
107  void IsHidden(bool value);
108 
112  bool IsJoined();
113 
117  void IsJoined(bool value);
118 
122  bool IsPasswordProtected();
123 
127  void IsPasswordProtected(bool value);
128 
129  bool IsManaged();
130 
131  void IsManaged(bool value);
132 
133  long int MaxSpectators();
134  void MaxSpectators(long int value);
135 
136  boost::shared_ptr<map<string, string> > Properties();
137  void Properties(boost::shared_ptr<map<string, string> > value);
138 
145  boost::shared_ptr<vector<boost::shared_ptr<RoomVariable> > > GetVariables();
146 
156  boost::shared_ptr<RoomVariable> GetVariable(string name);
157 
164  long int UserCount();
165 
172  void UserCount(long int value);
173 
177  long int MaxUsers();
178 
182  void MaxUsers(long int value);
183 
187  long int Capacity();
188 
192  long int SpectatorCount();
193 
197  void SpectatorCount(long int value);
198 
208  boost::shared_ptr<User> GetUserByName(string name);
209 
219  boost::shared_ptr<User> GetUserById(long int id);
220 
224  boost::shared_ptr<vector<boost::shared_ptr<User> > > UserList();
225 
226  boost::shared_ptr<vector<boost::shared_ptr<User> > > PlayerList();
227 
228  boost::shared_ptr<vector<boost::shared_ptr<User> > > SpectatorList();
229 
230  void RemoveUser(boost::shared_ptr<User> user);
231 
232  void SetVariable(boost::shared_ptr<RoomVariable> roomVariable);
233 
234  void SetVariables(boost::shared_ptr<vector<boost::shared_ptr<RoomVariable> > > roomVariables);
235 
245  bool ContainsVariable(string name);
246 
247  void AddUser(boost::shared_ptr<User> user);
248 
258  bool ContainsUser(boost::shared_ptr<User> user);
259 
260  boost::shared_ptr<IRoomManager> RoomManager();
261  void RoomManager(boost::shared_ptr<IRoomManager> value);
262 
263  boost::shared_ptr<string> ToString();
264 
265  void Merge(boost::shared_ptr<Room> anotherRoom);
266 
267  // -------------------------------------------------------------------
268  // Public members
269  // -------------------------------------------------------------------
270 
271  protected:
272 
273  // -------------------------------------------------------------------
274  // Protected methods
275  // -------------------------------------------------------------------
276 
277  // -------------------------------------------------------------------
278  // Protected members
279  // -------------------------------------------------------------------
280 
281  long int id;
282  boost::shared_ptr<string> name;
283  boost::shared_ptr<string> groupId;
284  bool isGame;
285  bool isHidden;
286  bool isJoined;
287  bool isPasswordProtected;
288  bool isManaged;
289  boost::shared_ptr<map<string, boost::shared_ptr<RoomVariable> > > variables;
290  boost::shared_ptr<map<string, string> > properties;
291  boost::shared_ptr<IUserManager> userManager;
292  long int maxUsers;
293  long int maxSpectators;
294  long int userCount; // only for non joined rooms
295  long int specCount; // only for non joined rooms
296  boost::shared_ptr<IRoomManager> roomManager;
297 
298  private:
299 
300  // -------------------------------------------------------------------
301  // Private methods
302  // -------------------------------------------------------------------
303 
304  void Init(long int id, string name, string groupId);
305  void RemoveUserVariable(string varName);
306 
307  // -------------------------------------------------------------------
308  // Private members
309  // -------------------------------------------------------------------
310  };
311 
312 } // namespace Entities
313 } // namespace Sfs2X
314 
315 #endif
The Room object represent a server Room.
Definition: SFSRoom.h:56
Definition: SFSCodecError.cpp:14
STL namespace.
Definition: IBuddyManager.h:32
Definition: BuddyOnlineState.h:15
Definition: BaseVariable.cpp:15
Definition: SmartFox.cpp:24
Definition: ISFSArray.h:17