- Timestamp:
- Dec 3, 2008, 5:35:20 PM (16 years ago)
- Location:
- code/branches/network/src/network
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/TrafficControl.cc
r2332 r2334 30 30 31 31 #include <cassert> 32 #include <boost/bind.hpp> 32 33 33 34 namespace network { … … 36 37 *Initializing protected members 37 38 */ 38 TrafficControl *Traffi Control::instance_=0;39 TrafficControl *TrafficControl::instance_=0; 39 40 40 41 /** … … 48 49 clientListPerm_ = new std::map<unsigned int,std::map<unsigned int, objInfo>>; 49 50 clientListTemp_ = new std::map std::map<unsigned int, std::map<unsigned int, std::vector<obj>>>; 50 referenceList_ = new std::map<unsigned int, Synchronisable*>;51 51 permObjPrio_ = new std::map<unsigned int, unsigned int> ; 52 52 schedObjPrio_ = new std::map<unsigned int, unsigned int> schedObjPrio_; … … 67 67 */ 68 68 69 TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj> *list) 69 /** 70 *eigener sortieralgorithmus 71 */ 72 bool TrafficControl::priodiffer(obj i, obj j) 73 { 74 map<unsigned int, objInfo>::iterator iti; 75 map<unsigned int, objInfo>::iterator itj; 76 iti=listToProcess_->find(i.objID); 77 itj=listToProcess_->find(j.objID); 78 return iti->second.objValuePerm < itj->second.objValuePerm; 79 } 80 81 82 83 std::vector<obj>* TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::vector<obj> *list) 70 84 { 71 85 copiedVector = *list; … … 79 93 } 80 94 81 TrafficControl::processAck(unsigned int clientID, unsigned int gamestateID)95 void TrafficControl::processAck(unsigned int clientID, unsigned int gamestateID) 82 96 { 83 97 map<unsigned int,std::map<unsigned int, objInfo>>::iterator itperm;//iterator clientListPerm … … 119 133 */ 120 134 121 //brauch ich die noch??,122 TrafficControl::createReferenceList(Synchronisable *list)123 {124 map<unsigned int, Synchronisable*>::iterator itref;125 itref=referenceList_->begin();126 referenceList_->insert(itref,pair<unsigned int, Synchronisable*>((*itref).getObjectID,(*itref).getSynchronisable));127 }128 //end brauch ich die noch129 135 130 136 /** 131 137 *copyList gets vector of Gamestate Manager and turns it to *listToProcess 132 138 */ 133 TrafficControl::copyList(std::map<obj> *list)139 void TrafficControl::copyList(std::map<obj> *list) 134 140 { 135 141 vector<obj>::iterator itvec; … … 139 145 (*objectA).objCreatorID=(*itvec).objCreatorID; 140 146 (*objectA).objSize = (*itvec).objSize; 141 (*listToProcess_).insert(pair<currentClientID, map<(*itvec).objID,objectA>>) //unsicher: ob map<...> so richtig ist147 (*listToProcess_).insert(pair<currentClientID, map<(*itvec).objID,objectA>>);//unsicher: ob map<...> so richtig ist 142 148 } 143 149 } … … 146 152 *returns void 147 153 */ 148 TrafficControl::updateReferenceList(std::map<unsigned int, objInfo> *list)149 { 150 map<unsigned int, Synchronisable*>::iterator itref;151 map<unsigned int, objInfo>::iterator itproc;154 void TrafficControl::updateReferenceList(std::map<unsigned int, objInfo> *list) 155 { 156 std::map<unsigned int, Synchronisable*>::iterator itref; 157 std::map<unsigned int, objInfo>::iterator itproc; 152 158 for(itproc=(*listToProcess_).begin();itproc != (*listToProcess_).end(); itproc++) 153 159 { … … 159 165 else 160 166 { 161 (*referenceList_).insert(pair<unsigned int, Synchronisable*>((*itproc).first,Synchronisable::getSynchronisable((*itproc).first)) ;//important: how to get adress of an object!167 (*referenceList_).insert(pair<unsigned int, Synchronisable*>((*itproc).first,Synchronisable::getSynchronisable((*itproc).first)));//important: how to get adress of an object! 162 168 insertinClientListPerm(currentClientID,itproc->first,itproc->second); 163 169 } … … 168 174 *returns void 169 175 */ 170 TrafficControl::insertinClientListPerm(unsigned int clientid, unsigned int objid, objInfo objinf)176 void TrafficControl::insertinClientListPerm(unsigned int clientid, unsigned int objid, objInfo objinf) 171 177 { 172 map<unsigned int,std::map<unsigned int, objInfo>>::iterator itperm;//iterator clientListPerm over clientIDs178 std::map<unsigned int,std::map<unsigned int, objInfo>>::iterator itperm;//iterator clientListPerm over clientIDs 173 179 itperm = (clientListPerm_).find(clientiD); 174 180 assert(itperm != clientListPerm_.end() ); … … 180 186 *evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this. 181 187 */ 182 TrafficControl::evaluateList(std::map<obj> *list)188 void TrafficControl::evaluateList(std::map<obj> *list) 183 189 { 184 190 copyList(list); … … 188 194 189 195 //compare listToProcess vs clientListPerm 190 map<unsigned int, objInfo>::iterator itproc;191 map<unsigned int,std::map<unsigned int, objInfo>>::iterator itperm;192 map<unsigned int, objInfo>::iterator itpermobj;193 map<unsigned int, unsigned int>::iterator itpermprio;196 std::map<unsigned int, objInfo>::iterator itproc; 197 std::map<unsigned int, std::map<unsigned int, objInfo>>::iterator itperm; 198 std::map<unsigned int, objInfo>::iterator itpermobj; 199 std::map<unsigned int, unsigned int>::iterator itpermprio; 194 200 for((*itproc=listToProcess_).begin(); itproc != (*listToProcess_).end();it++) 195 201 { … … 243 249 } 244 250 //sort copied vector aufgrund der objprioperm in clientlistperm 245 sort(copiedVector.begin(),copiedVector.end(),priodiffer); 251 // use boost bind here because we need to pass a memberfunction to stl sort 252 sort(copiedvector.begin(), copiedvector.end(), boost::bind(&TrafficControl::priodiffer,this,_1,_2) ); 246 253 //swappen aufgrund von creator oder ganz rausnehmen!? 247 254 for(itvec = copiedVector.begin(); itvec < copiedVector.end(); itvec++) -
code/branches/network/src/network/TrafficControl.h
r2332 r2334 63 63 }; 64 64 65 /** 66 *eigener sortieralgorithmus 67 */ 68 bool priodiffer(obj i, obj j) 69 { 70 map<unsigned int, objInfo>::iterator iti; 71 map<unsigned int, objInfo>::iterator itj; 72 iti=listToProcess_->find(i.objID); 73 itj=listToProcess_->find(j.objID); 74 return iti->second.objValuePerm < itj->second.objValuePerm; 75 } 65 76 66 77 67 /** … … 95 85 */ 96 86 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 97 /**98 *reference list: contains object ids and the reference belonging to this id.99 */100 //std::map<unsigned int, Synchronisable*> *referenceList_;//has to be created with constructor and then needs to be updated by evaluateList().101 87 /** 102 88 *permanent client list: contains client ids, object ids and objectInfos (in this order) … … 131 117 void updateReferenceList(std::map<unsigned int, objInfo> *list);//done 132 118 void insertinClientListPerm(unsigned int objid, objInfo objinf);//done 133 void createReferenceList(Synchronisable *list);//done134 119 /** 135 120 *creates listToProcess, which can be easialy compared with other lists … … 161 146 //done 162 147 void deleteObject(unsigned int objectID); // this function gets called when an object has been deleted (in order to clean up lists and maps) 148 149 bool priodiffer(obj i, obj j); 163 150 }; 164 151
Note: See TracChangeset
for help on using the changeset viewer.