Index: code/branches/network/src/network/TrafficControl.cc
===================================================================
--- code/branches/network/src/network/TrafficControl.cc	(revision 2317)
+++ code/branches/network/src/network/TrafficControl.cc	(revision 2332)
@@ -36,24 +36,30 @@
 *Initializing protected members
 */
-TrafficControl *TraffiControl::instance_=0;
-
-/**
- * @brief Constructor: assures that only one reference will be created and sets the pointer
- */
-TrafficControl::TrafficControl()
-{
-  assert(instance_=0);
-  instance_=this;
-  clientListPerm_=new std::map<unsigned int,std::map<unsigned int, objInfo>>;
-  referenceList_=new std::map<unsigned int, Synchronisable*>;
-}
-
-/**
- * @brief Destructor: resets the instance pointer to 0
- */
-TrafficControl::~TrafficControl()
-{
-  instance_=0;
-}
+	TrafficControl *TraffiControl::instance_=0;
+	
+	/**
+	* @brief Constructor: assures that only one reference will be created and sets the pointer
+	*/
+	TrafficControl::TrafficControl()
+	{
+	  assert(instance_=0);
+	  instance_=this;
+	  listToProcess_ = new std::map<unsigned int, objInfo>;
+	  clientListPerm_ = new std::map<unsigned int,std::map<unsigned int, objInfo>>;
+	  clientListTemp_ = new std::map std::map<unsigned int, std::map<unsigned int, std::vector<obj>>>;
+	  referenceList_ = new std::map<unsigned int, Synchronisable*>;
+	  permObjPrio_ = new std::map<unsigned int, unsigned int> ;
+	  schedObjPrio_ = new std::map<unsigned int, unsigned int> schedObjPrio_;
+	}
+	
+	/**
+	* @brief Destructor: resets the instance pointer to 0
+	*/
+	TrafficControl::~TrafficControl()
+	{ 
+	  //was macht das genau? da instance ja gleich this ist im moment
+	  instance_=0;
+	  //muss ich alles deallozieren was ich im constructor aufgebaut habe?
+	}
 
 /**
@@ -61,191 +67,201 @@
 */
 
-TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj> *list)
-{
-  currentClientID=clientID;
-  currentGamestateID=gamestateID;
-  list = evaluateList(list);
-  return list;
-}
+	TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj> *list)
+	{
+	  copiedVector = *list;
+	  currentClientID=clientID;
+	  currentGamestateID=gamestateID;
+	  evaluateList(list);
+	  //list hatte vorher ja vielmehr elemente, nach zuweisung nicht mehr... speicherplatz??
+	  list=copiedVector;
+          //später wird copiedVector ja überschrieben, ist das ein problem für list-dh. für gamestatemanager?
+	  return list;
+	}
+	
+	TrafficControl::processAck(unsigned int clientID, unsigned int gamestateID)
+	{
+	  map<unsigned int,std::map<unsigned int, objInfo>>::iterator itperm;//iterator clientListPerm
+	  map<unsigned int, objInfo>::iterator itpermoid;//iterator over objectid
+	  map<unsigned int, std::map<unsigned int, obj>>::iterator ittemp;//iterator clientListTemp, iterates over clientIDs
+	  map<unsigned int, unsigned int>::iterator ittempgs;//iterator that iterates over gsIDs of a client
+	  vector<obj>::iterator itvec;
+	  //following code helps to put clientListTemp infos into clientListPerm infos
+	  ittemp = (clientListTemp_).find(clientID);
+	  assert(ittemp != clientListTemp_.end() ); //muss da nicht was anderes überprüft werden?
+	  itperm = (clientListPerm_).find(clientID);
+	  assert(itperm != clientListPerm_.end() );
+	  ittempgs = (*ittemp).find(gamestateID);
+	  assert( ittempgs != (*ittemp).end() );//gleiche frage wie vorher
+	  for(itvec = *ittempgs.begin(); itvec = *ittempgs.end(); itvec++)
+	  { 
+	    if(itpermoid = (*itperm).find(itvec.objID))
+	    {
+	      if(gamestateID>(*itpermoid).second.objCurGS)
+	      {
+		(*itpermoid).second.objCurGS = gamestateID;
+	      }
+	      else continue;
+	    }
+	    else
+	    {
+	      objInfo objinf = new objInfo;
+	      objinf.objCurGS = gamestateID;
+	      insertinClientListPerm(clientID, itvec.objID, objinf);
+	    }
+	    //entferne objekt aus temporärer liste
+	    ittempgs.erase(itvec);
+	  }
+	
+	}
 
 /**
 *Definition of private members
 */
-
-//brauch ich die noch??
-TrafficControl::createReferenceList(Synchronisable *list)
-{
-  map<unsigned int, Synchronisable*>::iterator itref;
-  itref=referenceList_->begin();
-  referenceList_->insert(itref,pair<unsigned int, Synchronisable*>(itref->getObjectID,itref->getSynchronisable));
-}
-//end brauch ich die noch
-
-/**
-*copyList gets vector of Gamestate Manager and turns it to *listToProcess
-*/
-TrafficControl::copyList(std::map<obj> *list)
-{
-  listToProcess_=new std::map<unsigned int,std::map<unsigned int, unsigned int>>;
-  vector<obj>::iterator itvec;
-  for(itvec = list->begin(); itvec < list->end(); itvec++)
-  {
-   objInfo * objectA = new objInfo;
-   objectA.objCreatorID=*itvec.objCreatorID;
-   objectA.objSize = *itvec.objSize;
-   listToProcess_->insert(pair<currentClientID, map<*itvec.objID,objectA>)//unsicher: ob map<...> so richtig ist
-  }
-}
-/**
-*updateReferenceList compares the sent list by GSmanager with *the current reference list and updates it.
-*returns void
-*/
-TrafficControl::updateReferenceList(std::map<unsigned int, objInfo> *list)
-{
-  map<unsigned int, Synchronisable*>::iterator itref;
-  map<unsigned int, objInfo>::iterator itproc;
-  for(itproc=listToProcess_->begin();itproc != listToProcess_->.end(); itproc++)
-  {
-    //itproc->first=objectid that is looked for
-    if(referenceList_->find(itproc->first))
-    {
-      continue;
-    }
-    else
-    {
-      referenceList_->insert(pair<unsigned int, Synchronisable*>(itproc->first,Synchronisable::getSynchronisable(itproc->first));
-      insertinClientListPerm(itproc->first,itproc->second);
-    }
-  }
-}
-/**
-*updateClientListPerm
-*returns void
-*/
-TrafficControl::insertinClientListPerm(unsigned int objid, objInfo objinf)
-{
-  clientListPerm_->insert(pair<unsigned int,objInfo>(objid,objinf));
-}
-
-
-/**
-*evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this.
-*/
-TrafficControl::evaluateList(std::map<obj> *list)
-{
-  copyList(list);
-  updateReferenceList(listToProcess_);
-  
-  //now the sorting
-
-  //compare listToProcess vs clientListPerm
-  map<unsigned int, objInfo>::iterator itproc;
-  map<unsigned int,std::map<unsigned int, objInfo>>::iterator itperm;
-  map<unsigned int, objInfo>::iterator itpermobj;
-  map<unsigned int, unsigned int>::iterator itpermprio
-  for(itproc=listToProcess_->begin(); itproc != listToProcess_->end();it++)
-  {
-    itperm=clientListPerm->find(currentClientID);
-    itpermobj=itperm->find(itproc->first);
-    if(currentGamestateID < (itpermobj->second).objCurGS)
-    {
-      //obj bleibt in liste und permanente prio wird berechnet
-      (itpermobj->second).objDiffGS = (itpermobj->second).objCurGS - currentGamestateID;
-      itpermprio = permObjPrio_->find(itproc->first);
-      (itpermobj->second).objValuePerm = (itpermobj->second).objDiffGS * itpermprio->second;
-      continue;//check next objId
-    }
-    else
-    {
-      listToProcess_->erase (itproc);
-    }
-  }
-  //end compare listToProcess vs clientListPerm
-
-  //listToProc vs clientListTemp
-  map<unsigned int, std::map<unsigned int, unsigned int>>::iterator ittemp;
-  map<unsigned int, unsigned int>::iterator ittempgs;
-  for(itproc=listToProcess_->begin(); itproc != listToProcess_->end();it++)
-  {
-    ittemp = clientListTemp_->find(currentClientID);
-    if(ittempgs = ittemp->find(currentGamestateID))
-    {
-      if(itproc->first == ittempgs->find(itproc->first))
-      {
-        listToProcess_->erase (itproc);
+	
+	//brauch ich die noch??,
+	TrafficControl::createReferenceList(Synchronisable *list)
+	{
+	  map<unsigned int, Synchronisable*>::iterator itref;
+	  itref=referenceList_->begin();
+	  referenceList_->insert(itref,pair<unsigned int, Synchronisable*>((*itref).getObjectID,(*itref).getSynchronisable));
+	}
+	//end brauch ich die noch
+	
+	/**
+	*copyList gets vector of Gamestate Manager and turns it to *listToProcess
+	*/
+	TrafficControl::copyList(std::map<obj> *list)
+	{
+	  vector<obj>::iterator itvec;
+	  for(itvec = (*list).begin(); itvec < (*list).end(); itvec++)
+	  {
+	    objInfo objectA = new objInfo;
+	    (*objectA).objCreatorID=(*itvec).objCreatorID;
+	    (*objectA).objSize = (*itvec).objSize;
+	    (*listToProcess_).insert(pair<currentClientID, map<(*itvec).objID,objectA>>)//unsicher: ob map<...> so richtig ist
+	  }
+	}
+	/**
+	*updateReferenceList compares the sent list by GSmanager with the current *reference list and updates it.
+	*returns void
+	*/
+	TrafficControl::updateReferenceList(std::map<unsigned int, objInfo> *list)
+	{
+	  map<unsigned int, Synchronisable*>::iterator itref;
+	  map<unsigned int, objInfo>::iterator itproc;
+	  for(itproc=(*listToProcess_).begin();itproc != (*listToProcess_).end(); itproc++)
+	  {
+	    //itproc->first=objectid that is looked for
+	    if(referenceList_->find(itproc->first))
+	    {
+	      continue;
+	    }
+	    else
+	    {
+	      (*referenceList_).insert(pair<unsigned int,          Synchronisable*>((*itproc).first,Synchronisable::getSynchronisable((*itproc).first));//important: how to get adress of an object!
+	      insertinClientListPerm(currentClientID,itproc->first,itproc->second);
+	    }
+	  }
+	}
+	/**
+	*updateClientListPerm
+	*returns void
+	*/
+	TrafficControl::insertinClientListPerm(unsigned int clientid, unsigned int objid, objInfo objinf)
+	{ 
+	  map<unsigned int,std::map<unsigned int, objInfo>>::iterator itperm;//iterator clientListPerm over clientIDs
+	  itperm = (clientListPerm_).find(clientiD);
+	  assert(itperm != clientListPerm_.end() );
+	  (*itperm).insert(pair<unsigned int, objInfo>(objid,objinf));
+	}
+	
+	
+	/**
+	*evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this.
+	*/
+	TrafficControl::evaluateList(std::map<obj> *list)
+	{
+	  copyList(list);
+	  updateReferenceList(listToProcess_);
+	
+	  //now the sorting
+	
+	  //compare listToProcess vs clientListPerm
+	  map<unsigned int, objInfo>::iterator itproc;
+	  map<unsigned int,std::map<unsigned int, objInfo>>::iterator itperm;
+	  map<unsigned int, objInfo>::iterator itpermobj;
+	  map<unsigned int, unsigned int>::iterator itpermprio;
+	  for((*itproc=listToProcess_).begin(); itproc != (*listToProcess_).end();it++)
+	  {
+	    itperm=(clientListPerm_).find(currentClientID);
+	    itpermobj=(*itperm).find((*itproc).first);
+	    if(currentGamestateID < ((*itpermobj).second).objCurGS)
+	      {
+	      //obj bleibt in liste und permanente prio wird berechnet
+	        ((*itpermobj).second).objDiffGS = ((*itpermobj).second).objCurGS - currentGamestateID;
+	        itpermprio = (permObjPrio_).find((*itproc).first);
+	        ((*itpermobj).second).objValuePerm = ((*itpermobj).second).objDiffGS * (*itpermprio).second;
+	        continue;//check next objId
+	      }
+	      else
+	      {
+	        (listToProcess_).erase(itproc);
+	      }
+	  }
+	  //end compare listToProcess vs clientListPerm
+	
+	//listToProc vs clientListTemp
+	map<unsigned int, std::map<unsigned int, unsigned int>>::iterator ittemp;
+	map<unsigned int, unsigned int>::iterator ittempgs;
+	for((itproc=listToProcess_).begin(); itproc != (listToProcess_).end();itproc++)
+	{
+	  ittemp = clientListTemp_->find(currentClientID);
+	  if(ittempgs = (*ittemp).find(currentGamestateID))
+	  {
+	    if((*itproc).first == (*ittempgs).find((*itproc).first))//ja, dann ist objekt schon in der zu sendenden liste-muss nicht nochmal gesendet werden
+	    {
+ 	      (listToProcess_).erase (itproc);
+	    }
+            else continue;
+          }
+	  else continue;
+	}
+	//end listToProc vs clientListTemp
+	
+	//listToProcess contains obj to send now, shorten copiedvector therefor too.
+	vector<obj>::iterator itvec;
+	for(itvec = copiedVector.begin(); itvec < copiedVector.end(); itvec++)
+	{
+	  if((listToProcess_).find(itvec->objID))
+	  {
+            continue;//therefore object wasnt thrown out yet and has to be sent back to gsmanager
+          }
+	  else
+	  {
+	    copiedVector.remove(itvec);
+	  }
+	}
+	//sort copied vector aufgrund der objprioperm in clientlistperm
+	sort(copiedVector.begin(),copiedVector.end(),priodiffer);
+	//swappen aufgrund von creator oder ganz rausnehmen!?
+	for(itvec = copiedVector.begin(); itvec < copiedVector.end(); itvec++)
+	{ 
+	  itproc = (listToProcess_).find((*itvec).objID);
+	  if((*itproc).second.objCreatorID)
+	  {
+	  //vor dem child in copiedvector einfügen, wie?
+	    copiedVector.insert(copiedVector.find((*itproc).first),(*itproc).second.objCreatorID);
+	  }
+	  else continue;
+	}
+	  //end of sorting
+	  //now the cutting, work the same obj out in processobjectlist and copiedvector, compression rate muss noch festgelegt werden. 
+	  cut(copiedVector,currentClientID???bandWidth);
+	  //diese Funktion updateClientList muss noch gemacht werden
+	  updateClientListTemp(copiedVector);
+	  //end of sorting
       }
-      else continue;
-    }
-    else continue;
-  }
-  //end listToProc vs clientListTemp
-  
-  //listToProcess contains obj to send now, shorten copiedvector therefor too.
-  vector<obj>::iterator itvec;
-  for(itvec = copiedvector.begin(); itvec < copiedvector.end(); itvec++)
-  {
-    if(listToProcess_->find(itvec->objID))
-    {
-      continue;
-    }
-    else
-    {
-      copiedvector.remove(itvec);
-    }
-  }
-  //sort copied vector aufgrund der objprioperm in clientlistperm
-  sort(copiedvector.begin(),copiedvector.end(),priodiffer);
-  //swappen aufgrund von creator oder ganz rausnehmen!?
-  for(itvec = copiedVector.begin(); itvec < copiedVector.end(); itvec++)
-  { 
-    itproc = listToProcess_->find(itvec->objID);
-    if(itproc->second.objCreatorID)
-    {
-      //vor dem child in copiedvector einfügen, wie?
-      copiedVector.insert(itproc->second.objCreatorID);
-    }
-    else continue;
-  }
-  //end of sorting
-  //now the cutting, work the same obj out in processobjectlist and copiedvector, compression rate muss noch festgelegt werden. 
-  cut(copiedVector,compressionRate-1);
-  //diese Funktion updateClientList muss noch gemacht werden
-  updateClientListTemp(copiedVector);
-  //end of sorting
-}
-
-TrafficControl::processAck(unsigned int clientID, unsigned int gamestateID)
-{
-  map<unsigned int,std::map<unsigned int, objInfo>>::iterator itperm;
-  map<unsigned int, std::map<unsigned int, unsigned int>>::iterator ittemp;
-  map<unsigned int, unsigned int>::iterator ittempgs;
-  vector<obj>::iterator itvec;
-  //put temporarylist infos into permanentlist infos
-  ittemp = clientListTemp_->find(clientID);
-  assert(ittemp != clientListTemp_.end() );
-  ittempgs = (*ittemp).find(gamestateID);
-  assert( ittempgs != (*ittemp).end() );
-  for(itvec = *ittempgs.begin(); itvec = *ittempgs.end(); itvec++)
-  {
-    if(itperm = (*clientListPerm_).find(itvec.objID))
-    {
-      itperm = (*clientListPerm_).find(itvec.objID);
-      if(gamestateID>itperm.second.objCurGS)
-      {
-        itperm.second.objCurGS = gamestateID;
-      }
-      else continue;
-    }
-    else
-    {
-      objInfo objinf = new objInfo;
-      objinf.objCurGS = gamestateID;
-      insertinClientListPerm(itvec.objID, objinf);
-    }
-    //entferne objekt aus temporärer liste
-    ittempgs.erase(itvec);
-  }
-  
-}
+
+
 
 
Index: code/branches/network/src/network/TrafficControl.h
===================================================================
--- code/branches/network/src/network/TrafficControl.h	(revision 2317)
+++ code/branches/network/src/network/TrafficControl.h	(revision 2332)
@@ -39,14 +39,4 @@
 
 namespace network {
-
-// Synchronisable *bla = Synchronisable::getSynchronisable(objectID);
-
-//stuff to iterate through:  map<unsigned int, objInfo>::iterator itproc;
-//   map<unsigned int, Synchronisable>::iterator itref;
-//   for(it=listToProcess_->begin(); it != listToProcess_->end();it++)
-//   {
-//   
-//     itref=referenceList_->find((*itproc).first);
-//     refCurObj=(*itref).second;
 
 /**
@@ -91,17 +81,26 @@
   private:
 
+    /**
+    *Lists that will be used:
+    *listToProcess
+    *clientListPerm
+    *clientListTemp
+    *referenceList
+    *permObjPrio list
+    *schedObjPrio
+    */
     //start: lists to be used
     /**
     *creates list (typ map) that contains objids, struct with info concerning object(objid)
     */
-    std::map<unsigned int, objInfo> *listToProcess_;//copy of argument, when traffic control tool is being called, the original of this must be returned later on, eg the vector given by GS
+    std::map<unsigned int, objInfo> listToProcess_;//copy of argument, when traffic control tool is being called, the original of this must be returned later on, eg the vector given by GS
     /**
     *reference list: contains object ids and the reference belonging to this id.
     */
-//     std::map<unsigned int, Synchronisable*> *referenceList_;//has to be created with constructor and then needs to be updated by evaluateList().
+    //std::map<unsigned int, Synchronisable*> *referenceList_;//has to be created with constructor and then needs to be updated by evaluateList().
     /**
-    *permanent client list: contains client ids, gamestate ids and object ids (in this order)
+    *permanent client list: contains client ids, object ids and objectInfos (in this order)
     */
-    std::map<unsigned int, std::map<unsigned int, objInfo>> *clientListPerm_;
+    std::map<unsigned int, std::map<unsigned int, objInfo>> clientListPerm_;
     //has to be created with constructor and then needs to be updated by evaluateList().
 
@@ -109,13 +108,13 @@
     *temporary client list: contains client ids, gamestate ids and object ids (in this order)
     */
-    std::map<unsigned int, std::map<unsigned int, std::vector<obj>>> *clientListTemp_;
+    std::map<unsigned int, std::map<unsigned int, std::vector<obj>>> clientListTemp_;
     /**
     *static priority list: contains obj id, basic priority (in this order)
     */
-    std::map<unsigned int, unsigned int> *permObjPrio_;
+    std::map<unsigned int, unsigned int> permObjPrio_;
     /**
     *dynamic priority list: contains obj id, dynamic priority (eg scheduled) (in this order)
     */
-    std::map<unsigned int, unsigned int> *schedObjPrio_;
+    std::map<unsigned int, unsigned int> schedObjPrio_;
     //end: lists to be used
 
@@ -125,25 +124,23 @@
     unsigned int currentGamestateID;
     unsigned int currentClientID;
-    Synchronisable *refCurObj;//reference to current object, uninitialized yet, do I have to or can I just set refCurObj=...; later on? 
-    //not used yet anyway
-    std::vector<obj> copiedVector; //copy of original that I get from GSmanager
+    /**
+    *copiedVector is a copy of the given Vector by the GSmanager, on this vector all manipulations are performed
+    */
+    std::vector<obj> copiedVector;
 
-    void updateReferenceList(std::map<unsigned int, objInfo> *list);
-    void insertinClientListPerm(unsigned int objid, objInfo objinf);
+    void updateReferenceList(std::map<unsigned int, objInfo> *list);//done
+    void insertinClientListPerm(unsigned int objid, objInfo objinf);//done
+    void createReferenceList(Synchronisable *list);//done
     /**
     *creates listToProcess, which can be easialy compared with other lists
     */
-    void copyList(std::vector<obj> *list);
-    /**
-    *copies Data to be updated into vector, therefore vector can trashed by server
-    */
-    std::vector<unsigned int>* copyBackList(std::map<unsigned int,Synchronisable*>);
+    void copyList(std::vector<obj> *list);//done
+    
+    void cut(vector<obj> *list,int bandwidth);
+    void updateClientListTemp(vector<obj> *list);
     /**
     *evaluates Data given (vector) and produces result(->Data to be updated)
     */
     void evaluateList(std::map<obj> *list);
-
-
-
 
   protected:
@@ -160,5 +157,7 @@
     */
     std::vector<obj>* processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj>* list); //gets a pointer to the vector (containing objectIDs) and sorts it
+    //done
     void processAck(unsigned int clientID, unsigned int gamestateID);	// this function gets called when the server receives an ack from the client
+    //done
     void deleteObject(unsigned int objectID);				// this function gets called when an object has been deleted (in order to clean up lists and maps)
 };
