summaryrefslogtreecommitdiff
path: root/src/PieceStorage.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-10-11 16:58:24 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-10-11 16:58:24 +0000
commit048a2cf59737f761876e81a77e8d064c45c752d7 (patch)
tree65c9d5498aafe6a8c8e640ddfcc43c7013504d0d /src/PieceStorage.h
parente26bbbb9eee140ba24402fe872a752b42f0077de (diff)
2007-10-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Implemented BitTorrent/http/ftp integrated download. I've rewritten lots of files and now some headers have forward class declarations to reduce compile time. The implementation is extremely alpha stage, I recommend to use this for testing purpose only.
Diffstat (limited to 'src/PieceStorage.h')
-rw-r--r--src/PieceStorage.h42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/PieceStorage.h b/src/PieceStorage.h
index e41aeea6..64e6d523 100644
--- a/src/PieceStorage.h
+++ b/src/PieceStorage.h
@@ -36,9 +36,15 @@
#define _D_PIECE_STORAGE_H_
#include "common.h"
-#include "Peer.h"
-#include "Piece.h"
-#include "DiskAdaptor.h"
+#include "TimeA2.h"
+
+class Piece;
+extern typedef SharedHandle<Piece> PieceHandle;
+extern typedef deque<PieceHandle> Pieces;
+class Peer;
+extern typedef SharedHandle<Peer> PeerHandle;
+class DiskAdaptor;
+extern typedef SharedHandle<DiskAdaptor> DiskAdaptorHandle;
class PieceStorage {
public:
@@ -67,12 +73,30 @@ public:
virtual PieceHandle getMissingFastPiece(const PeerHandle& peer) = 0;
/**
+ * Returns a missing piece if available. Otherwise returns 0;
+ */
+ virtual PieceHandle getMissingPiece() = 0;
+
+ /**
+ * Returns a missing piece whose index is index.
+ * If a piece whose index is index is already acquired or currently used,
+ * then returns 0.
+ * Also returns 0 if any of missing piece is not available.
+ */
+ virtual PieceHandle getMissingPiece(int32_t index) = 0;
+
+ /**
* Returns the piece denoted by index.
* No status of the piece is changed in this method.
*/
virtual PieceHandle getPiece(int32_t index) = 0;
/**
+ * Marks the piece whose index is index as missing.
+ */
+ virtual void markPieceMissing(int32_t index) = 0;
+
+ /**
* Tells that the download of the specfied piece completes.
*/
virtual void completePiece(const PieceHandle& piece) = 0;
@@ -88,6 +112,8 @@ public:
*/
virtual bool hasPiece(int32_t index) = 0;
+ virtual bool isPieceUsed(int32_t index) = 0;
+
virtual int64_t getTotalLength() = 0;
virtual int64_t getFilteredTotalLength() = 0;
@@ -163,9 +189,15 @@ public:
virtual void markAllPiecesDone() = 0;
/**
- * Validates file integrity by comparing checksums.
+ * Sets all bits in bitfield(0 to length) to 1.
*/
- virtual void checkIntegrity() = 0;
+ virtual void markPiecesDone(int64_t length) = 0;
+
+ virtual void addInFlightPiece(const Pieces& pieces) = 0;
+
+ virtual int32_t countInFlightPiece() = 0;
+
+ virtual Pieces getInFlightPieces() = 0;
};
typedef SharedHandle<PieceStorage> PieceStorageHandle;