AuroraRuntime/Source/Compression/AuCompressionInterceptor.hpp

54 lines
1.7 KiB
C++
Raw Normal View History

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuCompressionInterceptor.hpp
Date: 2022-9-14
Author: Reece
***/
#pragma once
#include <IO/Protocol/Protocol.hpp>
namespace Aurora::Compression
{
struct CompressionInterceptor : ICompressionInterceptor, IO::IStreamReader
{
CompressionInterceptor();
void Init(const AuSPtr<ICompressionStream> &pStream,
const AuSPtr<BaseStream> &pBaseStream);
bool OnDataAvailable(const AuSPtr<Memory::ByteBuffer> &pReadInByteBuffer,
const AuSPtr<Memory::ByteBuffer> &pWriteOutByteBuffer,
const AuSPtr<IO::Protocol::IProtocolPiece> &pProtocolPiece) override;
inline virtual IO::EStreamError IsOpen() override;
inline virtual IO::EStreamError Read(const Memory::MemoryViewStreamWrite &parameters) override;
inline virtual void Close() override;
void FlushNextFrame() override;
bool ConfigureAutoFlushPerFrame(bool bAutoFlush) override;
bool LimitHasHit() override;
void LimitReset() override;
void LimitSet(AuUInt uLength) override;
bool LimitPassthroughOnOverflow(bool bPassthrough) override;
AuUInt LimitGetIndex() override;
bool HasFailed() override;
private:
bool bErrorFlag_ {};
bool bSendFlush_ {};
bool bAutoFlush_ {};
AuSPtr<ICompressionStream> pStream_;
AuSPtr<BaseStream> pBaseStream_;
AuSPtr<Memory::ByteBuffer> pLastBuffer_;
AuUInt uCountMax_ { AuNumericLimits<AuUInt>::max() };
AuUInt uCount_ {};
bool bPassthrough_ {};
};
}