/* */ #ifndef D_SEGMENT_H #define D_SEGMENT_H #include "common.h" #include #include #include namespace aria2 { class Piece; class WrDiskCache; class Segment { public: virtual ~Segment() = default; virtual bool complete() const = 0; virtual size_t getIndex() const = 0; virtual int64_t getPosition() const = 0; virtual int64_t getPositionToWrite() const = 0; virtual int64_t getLength() const = 0; virtual int64_t getSegmentLength() const = 0; virtual int64_t getWrittenLength() const = 0; virtual void updateWrittenLength(int64_t bytes) = 0; // `begin' is a offset inside this segment. virtual bool updateHash(int64_t begin, const unsigned char* data, size_t dataLength) = 0; virtual bool isHashCalculated() const = 0; virtual std::string getDigest() = 0; virtual void clear(WrDiskCache* diskCache) = 0; virtual std::shared_ptr getPiece() const = 0; bool operator==(const Segment& segment) const { return getIndex() == segment.getIndex(); } }; } // namespace aria2 #endif // D_SEGMENT_H