/* */ #ifndef _D_PIECED_SEGMENT_H_ #define _D_PIECED_SEGMENT_H_ #include "Segment.h" namespace aria2 { class PiecedSegment:public Segment { private: /** * Piece class has length property but it is a actual length of piece. * The last piece likely have shorter length than the other length. */ int32_t _pieceLength; int32_t _overflowLength; SharedHandle _piece; int32_t _writtenLength; public: PiecedSegment(int32_t pieceLength, const SharedHandle& piece); virtual ~PiecedSegment(); virtual bool complete() const; virtual int32_t getIndex() const; virtual int64_t getPosition() const; virtual int64_t getPositionToWrite() const; virtual int32_t getLength() const; virtual int32_t getSegmentLength() const { return _pieceLength; } virtual int32_t getWrittenLength() const { return _writtenLength; } virtual int32_t getOverflowLength() const { return _overflowLength; } virtual void updateWrittenLength(int32_t bytes); virtual void clear(); virtual SharedHandle getPiece() const; }; typedef SharedHandle PiecedSegmentHandle; } // namespace aria2 #endif // _D_PIECED_SEGMENT_H_