SmartFoxServer 2X C++ API
SFSBuddyManager.h
1 // ===================================================================
2 //
3 // Description
4 // Contains the definition of SFSBuddyManager
5 //
6 // Revision history
7 // Date Description
8 // 30-Nov-2012 First version
9 //
10 // ===================================================================
11 #ifndef __SFSBuddyManager__
12 #define __SFSBuddyManager__
13 
14 #include "IBuddyManager.h"
15 #include "../../SmartFox.h"
16 #include "../SFSBuddy.h"
17 
18 #include <boost/shared_ptr.hpp> // Boost Asio shared pointer
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 <map> // STL library: map object
24 #include <vector> // STL library: vector object
25 #include <string> // STL library: string object
26 using namespace std; // STL library: declare the STL namespace
27 
28 using namespace Sfs2X;
29 using namespace Sfs2X::Entities;
30 using namespace Sfs2X::Entities::Variables;
31 
32 namespace Sfs2X {
33 namespace Entities {
34 namespace Managers {
35 
39  class DLLImportExport SFSBuddyManager : public IBuddyManager
40  {
41  public:
42 
43  // -------------------------------------------------------------------
44  // Public methods
45  // -------------------------------------------------------------------
46  SFSBuddyManager(boost::shared_ptr<SmartFox> sfs);
47  virtual ~SFSBuddyManager();
48  void Dispose();
49 
50  bool Inited();
51  void Inited(bool value);
52  void AddBuddy(boost::shared_ptr<Buddy> buddy);
53  void ClearAll();
54  boost::shared_ptr<Buddy> RemoveBuddyById(long int id);
55  boost::shared_ptr<Buddy> RemoveBuddyByName(string name);
56  boost::shared_ptr<Buddy> GetBuddyById(long int id);
57  bool ContainsBuddy(string name);
58  boost::shared_ptr<Buddy> GetBuddyByName(string name);
59  boost::shared_ptr<Buddy> GetBuddyByNickName(string nickName);
60  boost::shared_ptr<vector<boost::shared_ptr<Buddy> > > OfflineBuddies();
61  boost::shared_ptr<vector<boost::shared_ptr<Buddy> > > OnlineBuddies();
62  boost::shared_ptr<vector<boost::shared_ptr<Buddy> > > BuddyList();
63  boost::shared_ptr<BuddyVariable> GetMyVariable(string varName);
64  boost::shared_ptr<BuddyVariable> GetMyVariable(boost::shared_ptr<string> varName);
65  boost::shared_ptr<vector<boost::shared_ptr<BuddyVariable> > > MyVariables();
66  void MyVariables(boost::shared_ptr<vector<boost::shared_ptr<BuddyVariable> > > value);
67  bool MyOnlineState();
68  void MyOnlineState(bool value);
69  boost::shared_ptr<string> MyNickName();
70  void MyNickName(string value);
71  boost::shared_ptr<string> MyState();
72  void MyState(string value);
73  boost::shared_ptr<vector<string> > BuddyStates();
74  void BuddyStates(boost::shared_ptr<vector<string> > value);
75  void SetMyVariable(boost::shared_ptr<BuddyVariable> bVar);
76 
77  // -------------------------------------------------------------------
78  // Public members
79  // -------------------------------------------------------------------
80 
81  protected:
82 
83  // -------------------------------------------------------------------
84  // Protected methods
85  // -------------------------------------------------------------------
86 
87  // -------------------------------------------------------------------
88  // Protected members
89  // -------------------------------------------------------------------
90  boost::shared_ptr<map<string, boost::shared_ptr<Buddy> > > buddiesByName;
91  boost::shared_ptr<map<string, boost::shared_ptr<BuddyVariable> > > myVariables;
92  bool myOnlineState;
93  bool inited;
94 
95  private:
96 
97  // -------------------------------------------------------------------
98  // Private methods
99  // -------------------------------------------------------------------
100 
101  // -------------------------------------------------------------------
102  // Private members
103  // -------------------------------------------------------------------
104  boost::shared_ptr<vector<string> > buddyStates;
105  boost::shared_ptr<SmartFox> sfs;
106  boost::recursive_mutex lockBuddiesByName;
107  boost::recursive_mutex lockMyVariables;
108  };
109 
110 } // namespace Managers
111 } // namespace Entities
112 } // namespace Sfs2X
113 
114 #endif
STL namespace.
Definition: BaseVariable.cpp:15
The class manages the current User&#39;s Buddy List
Definition: SFSBuddyManager.h:39
The BuddyList Manager interface
Definition: IBuddyManager.h:37
Definition: Buddy.h:30
Definition: SmartFox.cpp:24