Upstream tarball 9597
[amule.git] / src / CorruptionBlackBox.h
blob8524a3f3ac3cf441194702aafb7fb11094da43e9
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2008-2009 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2008-2009 Stu Redman ( sturedman@amule.org )
6 // Copyright (C) 2002-2008 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / http://www.emule-project.net )
7 //
8 // Any parts of this program derived from the xMule, lMule or eMule project,
9 // or contributed by third-party developers are copyrighted by their
10 // respective authors.
12 // This program is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation; either version 2 of the License, or
15 // (at your option) any later version.
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #ifndef CORRUPTIONBLACKBOX_H
28 #define CORRUPTIONBLACKBOX_H
30 #include "Types.h"
31 #include <vector>
33 class CUpDownClient;
36 enum EBBRStatus{
37 BBR_NONE = 0,
38 BBR_VERIFIED,
39 BBR_CORRUPTED
43 class CCBBRecord
45 public:
46 CCBBRecord(uint64 nStartPos = 0, uint64 nEndPos = 0, uint32 dwIP = 0, EBBRStatus BBRStatus = BBR_NONE);
47 CCBBRecord(const CCBBRecord& cv) { *this = cv; }
48 CCBBRecord& operator=(const CCBBRecord& cv);
50 bool Merge(uint64 nStartPos, uint64 nEndPos, uint32 dwIP, EBBRStatus BBRStatus = BBR_NONE);
51 bool CanMerge(uint64 nStartPos, uint64 nEndPos, uint32 dwIP, EBBRStatus BBRStatus = BBR_NONE);
53 uint64 m_nStartPos;
54 uint64 m_nEndPos;
55 uint32 m_dwIP;
56 EBBRStatus m_BBRStatus;
59 typedef std::vector<CCBBRecord> CRecordArray;
62 class CCorruptionBlackBox
64 public:
65 CCorruptionBlackBox() {}
66 ~CCorruptionBlackBox() {}
67 void Init(uint64 nFileSize);
68 void Free();
69 void TransferredData(uint64 nStartPos, uint64 nEndPos, const CUpDownClient* pSender);
70 void VerifiedData(uint64 nStartPos, uint64 nEndPos);
71 void CorruptedData(uint64 nStartPos, uint64 nEndPos);
72 void EvaluateData(uint16 nPart);
75 private:
76 std::vector<CRecordArray> m_aaRecords;
79 #endif