Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2340


Ignore:
Timestamp:
Dec 3, 2008, 6:56:58 PM (16 years ago)
Author:
chpeter
Message:

finished-well, not really=)

Location:
code/branches/network/src/network
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/network/TrafficControl.cc

    r2334 r2340  
    5151          permObjPrio_ = new std::map<unsigned int, unsigned int> ;
    5252          schedObjPrio_ = new std::map<unsigned int, unsigned int> schedObjPrio_;
     53          copiedVector = new std::vector<obj>;
     54          targetSize = 5000;//5000bytes
    5355        }
    5456       
     
    180182          assert(itperm != clientListPerm_.end() );
    181183          (*itperm).insert(pair<unsigned int, objInfo>(objid,objinf));
    182         }
    183        
    184        
     184          (permObjPrio_).insert(objid,objinf.objValuePerm);
     185        }
     186       
     187        /**
     188        *updateClientListTemp
     189        *takes the shortened vector which will be sent to the gsmanager and puts the *info into clientListTemp
     190        */     
     191        TrafficControl::updateClientListTemp(std::vector<obj> *list)
     192        {
     193          vector<obj>::iterator itvec;
     194          map<unsigned int,std::map<unsigned int, obj>>::iterator ittemp;
     195          map<unsigned int, obj>::iterator ittempgs;
     196          ittemp = (clientListTemp_).find(currentClientID);
     197          ittempgs = (*ittemp).find(currentGamestateID);
     198          for(itvec=list.begin();itvec!=list.end(),itvec++)
     199          {
     200            ittempgs.insert(itvec);
     201          }
     202        }
     203
     204        /**
     205        *cut
     206        *takes the current vector that has to be returned to the gsmanager and shortens it in criteria of bandwidth of clientID(XY)
     207        */
     208        TrafficControl::cut(std::vector<obj> *list,int targetsize)
     209        {
     210          unsigned int size=0;
     211          vector<obj>::iterator itvec;
     212          itvec = list.begin();
     213          unsigned int i=0;
     214          while(size<targetsize && (itvec!=list.end()))
     215          {
     216            size = size + (*itvec).objSize;//objSize is given in bytes!??
     217            i++;
     218            itvec = list.begin()+i;
     219          }
     220          list.erase(itvec, list.end());
     221        }
     222
     223
    185224        /**
    186225        *evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this.
    187226        */
    188         void TrafficControl::evaluateList(std::map<obj> *list)
     227        void TrafficControl::evaluateList(std::vector<obj> *list)
    189228        {
    190229          copyList(list);
     
    194233       
    195234          //compare listToProcess vs clientListPerm
     235          //if listToProcess contains new Objects, add them to clientListPerm
    196236          std::map<unsigned int, objInfo>::iterator itproc;
    197237          std::map<unsigned int, std::map<unsigned int, objInfo>>::iterator itperm;
    198238          std::map<unsigned int, objInfo>::iterator itpermobj;
    199239          std::map<unsigned int, unsigned int>::iterator itpermprio;
    200           for((*itproc=listToProcess_).begin(); itproc != (*listToProcess_).end();it++)
     240          for((*itproc)=(listToProcess_).begin(); itproc != (listToProcess_).end();it++)
    201241          {
    202242            itperm=(clientListPerm_).find(currentClientID);
    203             itpermobj=(*itperm).find((*itproc).first);
    204             if(currentGamestateID < ((*itpermobj).second).objCurGS)
     243            if(itpermobj=(*itperm).find((*itproc).first))
     244            {
     245             if(currentGamestateID > ((*itpermobj).second).objCurGS)
    205246              {
    206247              //obj bleibt in liste und permanente prio wird berechnet
     
    214255                (listToProcess_).erase(itproc);
    215256              }
    216           }
     257             }
     258             else
     259             {
     260               insertinClientListPerm(currentClientID,(*itproc).first,(*itproc).second);
     261               itpermobj=(*itperm).find((*itproc).first)
     262               ((*itpermobj).second).objDiffGS = ((*itpermobj).second).objCurGS - currentGamestateID;
     263               itpermprio = (permObjPrio_).find((*itproc).first);
     264               ((*itpermobj).second).objValuePerm = ((*itpermobj).second).objDiffGS * (*itpermprio).second;
     265               continue;//check next objId
     266             }
     267            }
    217268          //end compare listToProcess vs clientListPerm
    218269       
     
    235286        //end listToProc vs clientListTemp
    236287       
    237         //listToProcess contains obj to send now, shorten copiedvector therefor too.
     288        //listToProcess contains obj to send now, and since we give gsmanager the copiedvector and not listToProcess shorten copiedvector therefor too.
    238289        vector<obj>::iterator itvec;
    239290        for(itvec = copiedVector.begin(); itvec < copiedVector.end(); itvec++)
     
    264315          //end of sorting
    265316          //now the cutting, work the same obj out in processobjectlist and copiedvector, compression rate muss noch festgelegt werden.
    266           cut(copiedVector,currentClientID???bandWidth);
     317          cut(copiedVector,targetSize);
    267318          //diese Funktion updateClientList muss noch gemacht werden
    268319          updateClientListTemp(copiedVector);
  • code/branches/network/src/network/TrafficControl.h

    r2334 r2340  
    110110    unsigned int currentGamestateID;
    111111    unsigned int currentClientID;
     112    unsigned int targetSize;
    112113    /**
    113114    *copiedVector is a copy of the given Vector by the GSmanager, on this vector all manipulations are performed
     
    116117
    117118    void updateReferenceList(std::map<unsigned int, objInfo> *list);//done
    118     void insertinClientListPerm(unsigned int objid, objInfo objinf);//done
     119    void insertinClientListPerm(unsigned int clientid, unsigned int objid, objInfo objinf);//done
    119120    /**
    120121    *creates listToProcess, which can be easialy compared with other lists
     
    122123    void copyList(std::vector<obj> *list);//done
    123124   
    124     void cut(vector<obj> *list,int bandwidth);
    125     void updateClientListTemp(vector<obj> *list);
     125    void cut(std::vector<obj> *list,int targetsize);
     126    void updateClientListTemp(std::vector<obj> *list);//done
    126127    /**
    127128    *evaluates Data given (vector) and produces result(->Data to be updated)
    128129    */
    129     void evaluateList(std::map<obj> *list);
     130    void evaluateList(std::vector<obj> *list);//done
    130131
    131132  protected:
Note: See TracChangeset for help on using the changeset viewer.