[Orxonox-commit 3070] r7765 - code/branches/presentation/src/libraries/network

smerkli at orxonox.net smerkli at orxonox.net
Wed Dec 15 15:27:23 CET 2010


Author: smerkli
Date: 2010-12-15 15:27:22 +0100 (Wed, 15 Dec 2010)
New Revision: 7765

Modified:
   code/branches/presentation/src/libraries/network/MasterServer.cc
   code/branches/presentation/src/libraries/network/MasterServerComm.cc
   code/branches/presentation/src/libraries/network/MasterServerComm.h
Log:
prepared MSC for singleton usage.

Modified: code/branches/presentation/src/libraries/network/MasterServer.cc
===================================================================
--- code/branches/presentation/src/libraries/network/MasterServer.cc	2010-12-15 13:56:28 UTC (rev 7764)
+++ code/branches/presentation/src/libraries/network/MasterServer.cc	2010-12-15 14:27:22 UTC (rev 7765)
@@ -193,7 +193,7 @@
         std::string name = std::string( addrconv );
 
         /* remove the server from the list it belongs to */
-        this->mainlist.delServerByName( name );
+        this->mainlist.delServerByAddress( name );
 
         /* tell the user */
         COUT(2) << "Removed server " << name << " from list.\n";

Modified: code/branches/presentation/src/libraries/network/MasterServerComm.cc
===================================================================
--- code/branches/presentation/src/libraries/network/MasterServerComm.cc	2010-12-15 13:56:28 UTC (rev 7764)
+++ code/branches/presentation/src/libraries/network/MasterServerComm.cc	2010-12-15 14:27:22 UTC (rev 7765)
@@ -30,6 +30,7 @@
 
 namespace orxonox
 {
+  ManageScopedSingleton(MasterServerComm, ScopeID::Root, true);
  
   MasterServerComm::MasterServerComm()
   { /* nothing anymore, everything's been outsourced to 

Modified: code/branches/presentation/src/libraries/network/MasterServerComm.h
===================================================================
--- code/branches/presentation/src/libraries/network/MasterServerComm.h	2010-12-15 13:56:28 UTC (rev 7764)
+++ code/branches/presentation/src/libraries/network/MasterServerComm.h	2010-12-15 14:27:22 UTC (rev 7765)
@@ -35,10 +35,13 @@
 #include <cstring>
 #include <enet/enet.h>
 
+// tolua_begin
 namespace orxonox
 {
-  class MasterServerComm
-  {
+  class _NetworkExport MasterServerComm 
+    : public Singleton<MasterServerComm>, public OrxonoxClass
+  { // tolua_export
+    friend class Singleton<MasterServerComm>;
     public: 
       /** constructor */
       MasterServerComm();
@@ -88,6 +91,12 @@
        * Poll the master server for new data and act accordingly */
       int pollForReply( int (*callback)( char*, ENetEvent* ), int delayms );
 
+      /** \return an instance of WANDiscovery
+       * 
+       * Create and return an instance of WANDiscovery.
+       */
+      static MasterServerComm& getInstance() { return Singleton<MasterServerComm>::getInstance(); } // tolua_export
+
     private:
       /** client handle */
       ENetHost *client;
@@ -100,8 +109,11 @@
 
       /** peer data holder */
       ENetPeer *peer;
-  };
 
-}
+      /** Singleton pointer */
+      static MasterServerComm* singletonPtr_s;
+  }; // tolua_export
 
+} // tolua_export
+
 #endif /* MASTERSERVERCOMM_H */




More information about the Orxonox-commit mailing list