/* */ #ifndef D_STREAM_FILTER_H #define D_STREAM_FILTER_H #include "common.h" #include #include "SharedHandle.h" namespace aria2 { class BinaryStream; class Segment; // Interface for basic decoding functionality. class StreamFilter { private: SharedHandle delegate_; public: StreamFilter (const SharedHandle& delegate = SharedHandle()); virtual ~StreamFilter(); // init() must be called before calling decode(). virtual void init() = 0; // Returns the number of bytes written to sink virtual ssize_t transform(const SharedHandle& out, const SharedHandle& segment, const unsigned char* inbuf, size_t inlen) = 0; virtual bool finished() = 0; // The call of release() will free allocated resources. // After calling release(), the object can be reused by calling init(). virtual void release() = 0; virtual const std::string& getName() const = 0; // Returns the number of input bytes processed in the last // tranfrom() invocation. virtual size_t getBytesProcessed() const = 0; virtual bool installDelegate(const SharedHandle& filter); SharedHandle getDelegate() const { return delegate_; } }; } // namespace aria2 #endif // D_STREAM_FILTER_H