- Timestamp:
- Sep 24, 2009, 2:47:53 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/network/packet/ClassID.cc
r5738 r5778 49 49 Identifier *id; 50 50 std::string classname; 51 unsigned int nrOfClasses=0; 51 unsigned int nrOfClasses=0; 52 52 unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nrofclasses 53 53 uint32_t network_id; 54 54 flags_ = flags_ | PACKET_FLAGS_CLASSID; 55 55 std::queue<std::pair<uint32_t, std::string> > tempQueue; 56 56 57 57 //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){ 60 60 id = (*it).second; 61 if(id == NULL )61 if(id == NULL || !id->hasFactory()) 62 62 continue; 63 63 classname = id->getName(); … … 70 70 packetSize += (classname.size()+1)+sizeof(uint32_t)+sizeof(uint32_t); 71 71 } 72 72 73 73 this->data_=new uint8_t[ packetSize ]; 74 74 //set the appropriate packet id 75 75 assert(this->data_); 76 76 *(Type::Value *)(this->data_ + _PACKETID ) = Type::ClassID; 77 77 78 78 uint8_t *temp=data_+sizeof(uint32_t); 79 79 // save the number of all classes 80 80 *(uint32_t*)temp = nrOfClasses; 81 81 temp += sizeof(uint32_t); 82 82 83 83 // now save all classids and classnames 84 84 std::pair<uint32_t, std::string> tempPair; … … 91 91 temp+=2*sizeof(uint32_t)+tempPair.second.size()+1; 92 92 } 93 93 94 94 COUT(5) << "classid packetSize is " << packetSize << endl; 95 95 96 96 } 97 97 … … 111 111 temp += sizeof(uint32_t); 112 112 totalsize += sizeof(uint32_t); // storage size for nr of all classes 113 113 114 114 for(unsigned int i=0; i<nrOfClasses; i++){ 115 115 totalsize += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t)); … … 125 125 uint32_t stringsize; 126 126 unsigned char *classname; 127 128 129 //clea nthe map of network ids130 Factory::cleanNetworkIDs();131 127 128 129 //clear the map of network ids 130 Identifier::clearNetworkIDs(); 131 132 132 COUT(4) << "=== processing classids: " << endl; 133 133 std::pair<uint32_t, std::string> tempPair; … … 136 136 nrOfClasses = *(uint32_t*)temp; 137 137 temp += sizeof(uint32_t); 138 138 139 139 for( int i=0; i<nrOfClasses; i++){ 140 140 networkID = *(uint32_t*)temp;
Note: See TracChangeset
for help on using the changeset viewer.