AuroraRuntime/Source/IO/Protocol/AuProtocolStack.hpp

69 lines
2.9 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuProtocolStack.hpp
Date: 2022-8-24
Author: Reece
***/
#pragma once
#include "../AuIOPipeProcessor.hpp"
namespace Aurora::IO::Protocol
{
struct ProtocolPiece;
struct ProtocolStack : IProtocolStack,
AuEnableSharedFromThis<ProtocolStack>
{
~ProtocolStack();
void Terminate();
bool DoTick() override;
bool DoTick(const AuSPtr<AuByteBuffer> &read, const AuSPtr<ProtocolPiece> &pPiece);
AuSPtr<IProtocolPiece> AppendInterceptor(const AuSPtr<IProtocolInterceptor> &pInterceptor, AuUInt uOutputBufferSize) override;
AuSPtr<IProtocolPiece> AppendInterceptorEx(const AuSPtr<IProtocolInterceptorEx> &pInterceptor, AuUInt uOutputBufferSize) override;
AuSPtr<IProtocolPiece> AppendSingleFrameProcessor(const AuSPtr<IProtocolInterceptorEx> &pInterceptorEx) override;
AuSPtr<IProtocolPiece> AppendSingleFrameProcessorEx(const AuSPtr<IProtocolInterceptorEx> &pInterceptorEx, AuUInt uOutputBufferSize) override;
AuSPtr<IProtocolPiece> PrependInterceptor(const AuSPtr<IProtocolInterceptor> &pInterceptor, AuUInt uOutputBufferSize) override;
AuSPtr<IProtocolPiece> PrependInterceptorEx(const AuSPtr<IProtocolInterceptorEx> &pInterceptor, AuUInt uOutputBufferSize) override;
AuSPtr<IProtocolPiece> PrependSingleFrameProcessor(const AuSPtr<IProtocolInterceptorEx> &pInterceptorEx) override;
AuSPtr<IProtocolPiece> PrependSingleFrameProcessorEx(const AuSPtr<IProtocolInterceptorEx> &pInterceptorEx, AuUInt uOutputBufferSize) override;
AuSPtr<IProtocolPiece> AddEndInterceptor(const AuSPtr<IProtocolInterceptorEx> &pInterceptor) override;
void Destroy() override;
AuSPtr<IProtocolPiece> AddInterceptorWhere(bool bPrepend, const AuSPtr<IProtocolInterceptor> &pInterceptor, AuUInt uOutputBufferSize);
AuSPtr<IProtocolPiece> AddInterceptorWhereEx(bool bPrepend, const AuSPtr<IProtocolInterceptorEx> &pInterceptor, AuUInt uOutputBufferSize, bool bMultipleTick);
AuSPtr<IStreamWriter> AsStreamWriter() override;
AuSPtr<Memory::ByteBuffer> AsWritableByteBuffer() override;
AuSPtr<IStreamReader> AsStreamReader() override;
AuSPtr<Memory::ByteBuffer> AsReadableByteBuffer() override;
AuList<AuSPtr<IProtocolPiece>> GetArrayOfInterceptors() override;
AuSPtr<IProtocolPiece> GetInterceptorAtIndex(AuUInt32 uIndex) override;
AuSPtr<AuByteBuffer> pSourceBufer;
bool bOwnsSource {};
AuSPtr<AuByteBuffer> pDrainBuffer;
AuSPtr<ProtocolPiece> pBottomPiece;
AuSPtr<ProtocolPiece> pTopPiece;
bool bWrittenEnd {};
AuWPtr<AuIO::IOPipeWork> pPipeWork;
bool bKillPipeOnFirstRootLevelFalse {};
AuSPtr<IStreamReader> pStreamReaderCache;
AuSPtr<IStreamWriter> pStreamWriterCache;
void DiscardAllocCaches();
};
}