Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 24, 2009, 2:47:53 AM (15 years ago)
Author:
landauf
Message:

Removed the Factory class.
Moved the networkID↔Identifier map from Factory to Identifier.
Replaced the name↔Identifier map from Factory with the already existing Identifier map in Identifier. This map additionally contains Identifiers without Factory. You can separate them with the new function identifier→hasFactory().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/libraries/network/packet/ClassID.cc

    r5738 r5778  
    4949  Identifier *id;
    5050  std::string classname;
    51   unsigned int nrOfClasses=0; 
     51  unsigned int nrOfClasses=0;
    5252  unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nrofclasses
    5353  uint32_t network_id;
    5454  flags_ = flags_ | PACKET_FLAGS_CLASSID;
    5555  std::queue<std::pair<uint32_t, std::string> > tempQueue;
    56  
     56
    5757  //calculate total needed size (for all strings and integers)
    58   std::map<std::string, Identifier*>::const_iterator it = Factory::getFactoryMapBegin();
    59   for(;it != Factory::getFactoryMapEnd();++it){
     58  std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin();
     59  for(;it != Identifier::getStringIdentifierMapEnd();++it){
    6060    id = (*it).second;
    61     if(id == NULL)
     61    if(id == NULL || !id->hasFactory())
    6262      continue;
    6363    classname = id->getName();
     
    7070    packetSize += (classname.size()+1)+sizeof(uint32_t)+sizeof(uint32_t);
    7171  }
    72  
     72
    7373  this->data_=new uint8_t[ packetSize ];
    7474  //set the appropriate packet id
    7575  assert(this->data_);
    7676  *(Type::Value *)(this->data_ + _PACKETID ) = Type::ClassID;
    77  
     77
    7878  uint8_t *temp=data_+sizeof(uint32_t);
    7979  // save the number of all classes
    8080  *(uint32_t*)temp = nrOfClasses;
    8181  temp += sizeof(uint32_t);
    82  
     82
    8383  // now save all classids and classnames
    8484  std::pair<uint32_t, std::string> tempPair;
     
    9191    temp+=2*sizeof(uint32_t)+tempPair.second.size()+1;
    9292  }
    93  
     93
    9494  COUT(5) << "classid packetSize is " << packetSize << endl;
    95  
     95
    9696}
    9797
     
    111111  temp += sizeof(uint32_t);
    112112  totalsize += sizeof(uint32_t); // storage size for nr of all classes
    113  
     113
    114114  for(unsigned int i=0; i<nrOfClasses; i++){
    115115    totalsize += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t));
     
    125125  uint32_t stringsize;
    126126  unsigned char *classname;
    127  
    128  
    129   //clean the map of network ids
    130   Factory::cleanNetworkIDs();
    131  
     127
     128
     129  //clear the map of network ids
     130  Identifier::clearNetworkIDs();
     131
    132132  COUT(4) << "=== processing classids: " << endl;
    133133  std::pair<uint32_t, std::string> tempPair;
     
    136136  nrOfClasses = *(uint32_t*)temp;
    137137  temp += sizeof(uint32_t);
    138  
     138
    139139  for( int i=0; i<nrOfClasses; i++){
    140140    networkID = *(uint32_t*)temp;
Note: See TracChangeset for help on using the changeset viewer.