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