Changeset 3015 for code/branches/netp3/src/network/TrafficControl.cc
- Timestamp:
- May 22, 2009, 9:46:53 AM (15 years ago)
- File:
-
- 1 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 );
Note: See TracChangeset
for help on using the changeset viewer.