Changeset 3015
- Timestamp:
- May 22, 2009, 9:46:53 AM (16 years ago)
- Location:
- code/branches/netp3/src/network
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/netp3/src/network/TrafficControl.cc
r2990 r3015 21 21 * 22 22 * Author: 23 * Oliver Scheuss <scheusso [at] ee.ethz.ch> , (C) 200823 * Oliver Scheuss <scheusso [at] ee.ethz.ch> 24 24 * Co-authors: 25 25 * ... … … 121 121 122 122 123 void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj> *list) 124 { 125 // copiedVector = *list; 123 void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj>& list) 124 { 126 125 currentClientID=clientID; 127 126 currentGamestateID=gamestateID; … … 138 137 void TrafficControl::ack(unsigned int clientID, unsigned int gamestateID) 139 138 { 140 std:: list<obj>::iterator itvec; // iterator to iterate through the acked objects139 std::vector<obj>::iterator itvec; // iterator to iterate through the acked objects 141 140 142 141 //assertions to make sure the maps already exist … … 176 175 { 177 176 std::map<unsigned int,std::map<unsigned int, objInfo> >::iterator itperm;//iterator clientListPerm over clientIDs 178 // itperm = (clientListPerm_).find(clientID);179 // assert(itperm != clientListPerm_.end() );180 177 unsigned int gsid=GAMESTATEID_INITIAL, gsdiff=currentGamestateID, prioperm=Synchronisable::getSynchronisable(objinf.objID)->getPriority(), priomom=0; 181 178 clientListPerm_[clientID][objinf.objID] = objInfo(objinf.objID, objinf.objCreatorID,gsid,gsdiff, objinf.objSize,prioperm,priomom); 182 // itperm->second.insert(std::pair<unsigned int, objInfo>(objid,objinf));183 // permObjPrio_.insert(objid, objinf.objValuePerm);184 179 } 185 180 … … 188 183 * takes the shortened list which will be sent to the gsmanager and puts the *info into clientListTemp 189 184 */ 190 void TrafficControl::updateClientListTemp(std:: list<obj> *list)191 { 192 clientListTemp_[currentClientID][currentGamestateID] = std:: list<obj>(*list);185 void TrafficControl::updateClientListTemp(std::vector<obj>& list) 186 { 187 clientListTemp_[currentClientID][currentGamestateID] = std::vector<obj>(list); 193 188 } 194 189 … … 197 192 *takes the current list that has to be returned to the gsmanager and shortens it in criteria of bandwidth of clientID(XY) 198 193 */ 199 void TrafficControl::cut(std:: list<obj> *list, unsigned int targetsize)194 void TrafficControl::cut(std::vector<obj>& list, unsigned int targetsize) 200 195 { 201 196 unsigned int size=0; 202 std:: list<obj>::iterator itvec, ittemp;203 assert(!list ->empty());204 for(itvec = list ->begin(); itvec != list->end();)197 std::vector<obj>::iterator itvec, ittemp; 198 assert(!list.empty()); 199 for(itvec = list.begin(); itvec != list.end();) 205 200 { 206 201 assert( (*itvec).objSize < 1000); … … 213 208 { 214 209 clientListPerm_[currentClientID][(*itvec).objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative 215 list ->erase(itvec++);210 list.erase(itvec++); 216 211 } 217 212 // printList(list, currentClientID); 218 213 } 219 assert(!list ->empty());214 assert(!list.empty()); 220 215 } 221 216 … … 224 219 *evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this. 225 220 */ 226 void TrafficControl::evaluateList(unsigned int clientID, std:: list<obj> *list)221 void TrafficControl::evaluateList(unsigned int clientID, std::vector<obj>& list) 227 222 { 228 223 … … 231 226 //compare listToProcess vs clientListPerm 232 227 //if listToProcess contains new Objects, add them to clientListPerm 233 std:: list<obj>::iterator itvec;234 for( itvec=list ->begin(); itvec != list->end(); itvec++)228 std::vector<obj>::iterator itvec; 229 for( itvec=list.begin(); itvec != list.end(); itvec++) 235 230 { 236 231 if ( clientListPerm_[clientID].find( (*itvec).objID) != clientListPerm_[clientID].end() ) … … 254 249 //sort copied list according to priorities 255 250 // use boost bind here because we need to pass a memberfunction to stl sort 256 list->sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) ); 251 sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) ); 252 // list.sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) ); 257 253 258 254 //now we check, that the creator of an object always exists on a client 259 std:: list<obj>::iterator itcreator;260 for(itvec = list ->begin(); itvec != list->end(); itvec++)255 std::vector<obj>::iterator itcreator; 256 for(itvec = list.begin(); itvec != list.end(); itvec++) 261 257 { 262 258 fixCreatorDependencies(itvec, list, clientID); … … 268 264 269 265 //now sort again after objDataOffset 270 list->sort(boost::bind(&TrafficControl::dataSort, this, _1, _2) );266 sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) ); 271 267 } 272 268 //diese Funktion updateClientList muss noch gemacht werden … … 275 271 } 276 272 277 void TrafficControl::printList(std:: list<obj> *list, unsigned int clientID)278 { 279 std:: list<obj>::iterator it;273 void TrafficControl::printList(std::vector<obj>& list, unsigned int clientID) 274 { 275 std::vector<obj>::iterator it; 280 276 COUT(0) << "=========== Objectlist ===========" << endl; 281 for( it=list ->begin(); it!=list->end(); it++)277 for( it=list.begin(); it!=list.end(); it++) 282 278 COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << " size: " << (*it).objSize << endl; 283 279 } 284 280 285 void TrafficControl::fixCreatorDependencies(std:: list<obj>::iterator it1, std::list<obj> *list, unsigned int clientID)281 void TrafficControl::fixCreatorDependencies(std::vector<obj>::iterator it1, std::vector<obj>& list, unsigned int clientID) 286 282 { 287 283 if ( (*it1).objCreatorID == OBJECTID_UNKNOWN ) … … 289 285 if( clientListPerm_[clientID][(*it1).objCreatorID].objCurGS != GAMESTATEID_INITIAL ) 290 286 return; 291 std:: list<obj>::iterator it2, it3=it1;292 for( it2 = ++it3; it2 != list ->end(); it2++ )287 std::vector<obj>::iterator it2, it3=it1; 288 for( it2 = ++it3; it2 != list.end(); it2++ ) 293 289 { 294 290 if( (*it2).objID == (*it1).objCreatorID ) 295 291 { 296 it3 = list ->insert(it1, *it2); //insert creator before it1297 list ->erase(it2);292 it3 = list.insert(it1, *it2); //insert creator before it1 293 list.erase(it2); 298 294 // printList(list, clientID); 299 295 fixCreatorDependencies( it3, list, clientID ); -
code/branches/netp3/src/network/TrafficControl.h
r2710 r3015 21 21 * 22 22 * Author: 23 * Oliver Scheuss <scheusso [at] ee.ethz.ch> , (C) 200823 * Oliver Scheuss <scheusso [at] ee.ethz.ch> 24 24 * Co-authors: 25 25 * ... … … 32 32 33 33 #include <string> 34 #include < list>34 #include <vector> 35 35 #include <map> 36 36 #include <utility> … … 83 83 84 84 /** 85 *Lists that will be used:86 *listToProcess87 *clientListPerm88 *clientListTemp89 *referenceList90 *permObjPrio list91 *schedObjPrio92 */93 //start: lists to be used94 /**95 *creates list (typ map) that contains objids, struct with info concerning object(objid)96 */97 // 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 list given by GS98 /**99 85 *permanent client list: contains client ids, object ids and objectInfos (in this order) 100 86 */ … … 105 91 *temporary client list: contains client ids, gamestate ids and object ids (in this order) 106 92 */ 107 std::map<unsigned int, std::map<unsigned int, std::list<obj> > > clientListTemp_; 108 /** 109 *static priority list: contains obj id, basic priority (in this order) 110 */ 111 // std::map<unsigned int, unsigned int> permObjPrio_; 112 /** 113 *dynamic priority list: contains obj id, dynamic priority (eg scheduled) (in this order) 114 */ 115 // std::map<unsigned int, unsigned int> schedObjPrio_; 116 //end: lists to be used 93 std::map<unsigned int, std::map<unsigned int, std::vector<obj> > > clientListTemp_; 117 94 118 95 /**updateReferenceList … … 123 100 unsigned int targetSize; 124 101 bool bActive_; 125 /**126 *copiedVector is a copy of the given Vector by the GSmanager, on this list all manipulations are performed127 */128 // std::list<obj> copiedVector;129 130 // void updateReferenceList(std::map<unsigned int, objInfo> *list);//done131 void insertinClientListPerm(unsigned int clientID, obj objinf);//done132 /**133 *creates listToProcess, which can be easialy compared with other lists134 */135 // void copyList(std::list<obj> *list);//done136 102 137 void cut(std::list<obj> *list, unsigned int targetsize); 138 void updateClientListTemp(std::list<obj> *list);//done 103 void insertinClientListPerm(unsigned int clientID, obj objinf); 104 105 void cut(std::vector<obj>& list, unsigned int targetsize); 106 void updateClientListTemp(std::vector<obj>& list);//done 139 107 /** 140 108 *evaluates Data given (list) and produces result(->Data to be updated) 141 109 */ 142 void evaluateList(unsigned int clientID, std:: list<obj> *list);//done110 void evaluateList(unsigned int clientID, std::vector<obj>& list);//done 143 111 void ack(unsigned int clientID, unsigned int gamestateID); // this function gets called when the server receives an ack from the client 144 112 … … 162 130 void setConfigValues(); 163 131 static TrafficControl *getInstance(); 164 void processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>* list); //gets a pointer to the list (containing objectIDs) and sorts it 165 //done 132 void processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj>& list); //gets a pointer to the list (containing objectIDs) and sorts it 166 133 static void processAck(unsigned int clientID, unsigned int gamestateID) 167 134 { return instance_->ack(clientID, gamestateID); } 168 //done169 135 void deleteObject(unsigned int objectID); // this function gets called when an object has been deleted (in order to clean up lists and maps) 170 136 171 137 bool prioritySort(uint32_t clientID, obj i, obj j); 172 138 bool dataSort(obj i, obj j); 173 void printList(std:: list<obj> *list, unsigned int clientID);174 void fixCreatorDependencies(std:: list<obj>::iterator it, std::list<obj> *list, unsigned int clientID);139 void printList(std::vector<obj>& list, unsigned int clientID); 140 void fixCreatorDependencies(std::vector<obj>::iterator it, std::vector<obj>& list, unsigned int clientID); 175 141 }; 176 142 -
code/branches/netp3/src/network/packet/Gamestate.cc
r3003 r3015 111 111 tempsize = it->getData(mem, id, mode); 112 112 if ( it->doSync( id, mode ) ) 113 data Map_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );113 dataVector_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) ); 114 114 115 115 #ifndef NDEBUG … … 364 364 Gamestate* Gamestate::doSelection(unsigned int clientID, unsigned int targetSize){ 365 365 assert(data_); 366 std:: list<obj>::iterator it;366 std::vector<obj>::iterator it; 367 367 368 368 // allocate memory for new data … … 383 383 384 384 //call TrafficControl 385 TrafficControl::getInstance()->processObjectList( clientID, header_->getID(), &dataMap_ );385 TrafficControl::getInstance()->processObjectList( clientID, header_->getID(), dataVector_ ); 386 386 387 387 //copy in the zeros 388 for(it=data Map_.begin(); it!=dataMap_.end();){388 for(it=dataVector_.begin(); it!=dataVector_.end();){ 389 389 SynchronisableHeader oldobjectheader(origdata); 390 390 SynchronisableHeader newobjectheader(newdata); -
code/branches/netp3/src/network/packet/Gamestate.h
r2896 r3015 37 37 #include <string.h> 38 38 #include <map> 39 #include < list>39 #include <vector> 40 40 #include <cassert> 41 41 #ifndef NDEBUG … … 129 129 private: 130 130 uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0); 131 std:: list<obj> dataMap_;131 std::vector<obj> dataVector_; 132 132 GamestateHeader* header_; 133 133 };
Note: See TracChangeset
for help on using the changeset viewer.