MCPcopy Create free account
hub / github.com/amule-project/amule / Encode

Method Encode

src/ExternalConn.cpp:1527–1638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1525}
1526
1527void CPartFile_Encoder::Encode(CECTag *parent)
1528{
1529 //
1530 // Source part frequencies
1531 //
1532 CKnownFile_Encoder::Encode(parent);
1533
1534 //
1535 // Gaps
1536 //
1537 const CGapList& gaplist = m_PartFile()->GetGapList();
1538 const size_t gap_list_size = gaplist.size();
1539 ArrayOfUInts64 gaps;
1540 gaps.reserve(gap_list_size * 2);
1541
1542 for (CGapList::const_iterator curr_pos = gaplist.begin();
1543 curr_pos != gaplist.end(); ++curr_pos) {
1544 gaps.push_back(curr_pos.start());
1545 gaps.push_back(curr_pos.end());
1546 }
1547
1548 int gap_enc_size = 0;
1549 bool changed;
1550 const uint8 *gap_enc_data = m_gap_status.Encode(gaps, gap_enc_size, changed);
1551 if (changed) {
1552 parent->AddTag(CECTag(EC_TAG_PARTFILE_GAP_STATUS, gap_enc_size, (void *)gap_enc_data));
1553 }
1554 delete[] gap_enc_data;
1555
1556 //
1557 // Requested blocks
1558 //
1559 ArrayOfUInts64 req_buffer;
1560 const CPartFile::CReqBlockPtrList& requestedblocks = m_PartFile()->GetRequestedBlockList();
1561 CPartFile::CReqBlockPtrList::const_iterator curr_pos2 = requestedblocks.begin();
1562
1563 for ( ; curr_pos2 != requestedblocks.end(); ++curr_pos2 ) {
1564 Requested_Block_Struct* block = *curr_pos2;
1565 req_buffer.push_back(block->StartOffset);
1566 req_buffer.push_back(block->EndOffset);
1567 }
1568 int req_enc_size = 0;
1569 const uint8 *req_enc_data = m_req_status.Encode(req_buffer, req_enc_size, changed);
1570 if (changed) {
1571 parent->AddTag(CECTag(EC_TAG_PARTFILE_REQ_STATUS, req_enc_size, (void *)req_enc_data));
1572 }
1573 delete[] req_enc_data;
1574
1575 //
1576 // Source names
1577 //
1578 // First count occurrence of all source names
1579 //
1580 CECEmptyTag sourceNames(EC_TAG_PARTFILE_SOURCE_NAMES);
1581 typedef std::map<wxString, int> strIntMap;
1582 strIntMap nameMap;
1583 const CPartFile::SourceSet &sources = m_PartFile()->GetSourceList();
1584 for (CPartFile::SourceSet::const_iterator it = sources.begin(); it != sources.end(); ++it) {

Calls 15

CECIntTagClass · 0.85
startMethod · 0.80
GetRequestedBlockListMethod · 0.80
LengthMethod · 0.80
eraseMethod · 0.80
HasChildTagsMethod · 0.80
CECTagClass · 0.70
SourcenameItemClass · 0.70
EncodeFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected