/* */ #ifndef _D_SEGMENT_H_ #define _D_SEGMENT_H_ #include "common.h" #include "SharedHandle.h" #include #include #include #include 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 size_t getOverflowLength() 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(); } }; typedef SharedHandle SegmentHandle; typedef std::deque Segments; } // namespace aria2 #endif // _D_SEGMENT_H_