[Orxonox-commit 5810] r10470 - in code/branches/core7/src/libraries/network: . packet

landauf at orxonox.net landauf at orxonox.net
Mon May 25 12:25:29 CEST 2015


Author: landauf
Date: 2015-05-25 12:25:29 +0200 (Mon, 25 May 2015)
New Revision: 10470

Modified:
   code/branches/core7/src/libraries/network/NetworkFunction.cc
   code/branches/core7/src/libraries/network/NetworkFunction.h
   code/branches/core7/src/libraries/network/packet/FunctionIDs.cc
Log:
NetworkFunctionBase doesn't have to inherit from Listable: there's a list of all instances stored in NetworkFunctionManager stored anyway

Modified: code/branches/core7/src/libraries/network/NetworkFunction.cc
===================================================================
--- code/branches/core7/src/libraries/network/NetworkFunction.cc	2015-05-25 10:16:43 UTC (rev 10469)
+++ code/branches/core7/src/libraries/network/NetworkFunction.cc	2015-05-25 10:25:29 UTC (rev 10470)
@@ -28,22 +28,14 @@
 
 #include "NetworkFunction.h"
 #include "NetworkFunctionManager.h"
-#include "core/CoreIncludes.h"
 
 namespace orxonox
 {
   std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::functorMap_;
   std::map<uint32_t, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::idMap_;
 
-  // no suitable factory for NetworkFunctionBase (and children), so we declare it abstract
-  RegisterAbstractClass(NetworkFunctionBase).inheritsFrom<Listable>();
-  RegisterAbstractClass(NetworkFunctionStatic).inheritsFrom<NetworkFunctionBase>();
-  RegisterAbstractClass(NetworkMemberFunctionBase).inheritsFrom<NetworkFunctionBase>();
-
   NetworkFunctionBase::NetworkFunctionBase(const std::string& name)
   {
-      RegisterObject(NetworkFunctionBase);
-
     static uint32_t networkID = 0;
     this->networkID_ = networkID++;
 
@@ -58,8 +50,6 @@
   NetworkFunctionStatic::NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p):
     NetworkFunctionBase(name)
   {
-    RegisterObject(NetworkFunctionStatic);
-
     this->functor_ = functor;
     NetworkFunctionStatic::getFunctorMap()[p] = this;
     NetworkFunctionStatic::getIdMap()[ this->getNetworkID() ] = this;
@@ -81,8 +71,6 @@
   NetworkMemberFunctionBase::NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p):
     NetworkFunctionBase(name)
   {
-    RegisterObject(NetworkMemberFunctionBase);
-
     this->functorMap_[p] = this;
     this->idMap_[ this->getNetworkID() ] = this;
   }

Modified: code/branches/core7/src/libraries/network/NetworkFunction.h
===================================================================
--- code/branches/core7/src/libraries/network/NetworkFunction.h	2015-05-25 10:16:43 UTC (rev 10469)
+++ code/branches/core7/src/libraries/network/NetworkFunction.h	2015-05-25 10:25:29 UTC (rev 10470)
@@ -36,8 +36,6 @@
 #include <map>
 #include <string>
 
-#include "core/object/Listable.h"
-#include "core/class/Identifier.h"
 #include "core/command/Functor.h"
 #include "FunctionCallManager.h"
 #include "synchronisable/Synchronisable.h"
@@ -68,10 +66,10 @@
 
 
 
-class _NetworkExport NetworkFunctionBase: virtual public Listable {
+class _NetworkExport NetworkFunctionBase {
   public:
     NetworkFunctionBase(const std::string& name);
-    ~NetworkFunctionBase();
+    virtual ~NetworkFunctionBase();
 
     virtual void        setNetworkID(uint32_t id)       { this->networkID_ = id; }
     inline uint32_t     getNetworkID() const            { return this->networkID_; }

Modified: code/branches/core7/src/libraries/network/packet/FunctionIDs.cc
===================================================================
--- code/branches/core7/src/libraries/network/packet/FunctionIDs.cc	2015-05-25 10:16:43 UTC (rev 10469)
+++ code/branches/core7/src/libraries/network/packet/FunctionIDs.cc	2015-05-25 10:25:29 UTC (rev 10470)
@@ -55,11 +55,12 @@
   std::queue<std::pair<uint32_t, std::string> > tempQueue;
 
   //calculate total needed size (for all strings and integers)
-  ObjectList<NetworkFunctionBase>::iterator it;
-  for(it = ObjectList<NetworkFunctionBase>::begin(); it; ++it)
+  std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionManager::getNameMap();
+  std::map<std::string, NetworkFunctionBase*>::iterator it;
+  for (it = map.begin(); it != map.end(); ++it)
   {
-    const std::string& functionname = it->getName();
-    networkID = it->getNetworkID();
+    const std::string& functionname = it->second->getName();
+    networkID = it->second->getNetworkID();
     // now push the network id and the classname to the stack
     tempQueue.push( std::pair<unsigned int, std::string>(networkID, functionname) );
     ++nrOfFunctions;




More information about the Orxonox-commit mailing list