/* */ #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 int64_t getPosition() const = 0; virtual int64_t getPositionToWrite() const = 0; virtual int32_t getLength() const = 0; virtual int32_t getSegmentLength() const = 0; virtual int32_t getWrittenLength() const = 0; virtual void updateWrittenLength(int32_t bytes) = 0; #ifdef ENABLE_MESSAGE_DIGEST // `begin' is a offset inside this segment. virtual bool updateHash (int32_t begin, const unsigned char* data, size_t dataLength) = 0; virtual bool isHashCalculated() const = 0; virtual std::string getDigest() = 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