89 lines
3.5 KiB
C++
89 lines
3.5 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"
|
|
#include "AuProtocolStackSpecialReader.hpp"
|
|
#include "AuProtocolStackSpecialWriter.hpp"
|
|
|
|
namespace Aurora::IO::Protocol
|
|
{
|
|
struct ProtocolPiece;
|
|
|
|
struct ProtocolStack : IProtocolStack,
|
|
AuEnableSharedFromThis<ProtocolStack>
|
|
{
|
|
ProtocolStack();
|
|
~ProtocolStack();
|
|
|
|
void Terminate();
|
|
bool DoTick() override;
|
|
bool DoTick(const AuSPtr<AuByteBuffer> &read, const AuSPtr<ProtocolPiece> &pPiece);
|
|
|
|
bool DoTickEx(bool bPermitRead = true);
|
|
|
|
bool TryReadMore(bool bForce = false);
|
|
|
|
AuSPtr<IProtocolPiece> AddInterceptor(EProtocolWhere eWhere, const AuSPtr<IProtocolInterceptor> &pInterceptor, AuUInt uOutputBufferSize) override;
|
|
AuSPtr<IProtocolPiece> AddInterceptorEx(EProtocolWhere eWhere, const AuSPtr<IProtocolInterceptorEx> &pInterceptor, AuUInt uOutputBufferSize) override;
|
|
AuSPtr<IProtocolPiece> AddSingleFrameProcessor(EProtocolWhere eWhere, const AuSPtr<IProtocolInterceptorEx> &pInterceptorEx) override;
|
|
AuSPtr<IProtocolPiece> AddSingleFrameProcessorEx(EProtocolWhere eWhere, const AuSPtr<IProtocolInterceptorEx> &pInterceptorEx, AuUInt uOutputBufferSize) override;
|
|
AuSPtr<IProtocolPiece> AddInterceptorDynamicBuffer(EProtocolWhere eWhere, const AuSPtr<IProtocolInterceptorEx> &pInterceptorEx, AuUInt uOutputBufferSize, AuUInt uOutputBufferSizeMax) override;
|
|
AuSPtr<IProtocolPiece> AddSingleFrameProcessorDynamicBuffer(EProtocolWhere eWhere, const AuSPtr<IProtocolInterceptorEx> &pInterceptorEx, AuUInt uOutputBufferSize, AuUInt uOutputBufferSizeMax) override;
|
|
|
|
AuSPtr<IProtocolPiece> AddEndInterceptor(const AuSPtr<IProtocolInterceptorEx> &pInterceptor) override;
|
|
|
|
void Destroy() override;
|
|
|
|
AuSPtr<IProtocolPiece> AddInterceptorWhere(EProtocolWhere eWhere, const AuSPtr<IProtocolInterceptor> &pInterceptor, AuUInt uOutputBufferSize);
|
|
AuSPtr<IProtocolPiece> AddInterceptorWhereEx(EProtocolWhere eWhere, const AuSPtr<IProtocolInterceptorEx> &pInterceptor, AuUInt uOutputBufferSize, bool bMultipleTick, AuOptional<AuUInt> uMax = {});
|
|
|
|
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;
|
|
|
|
bool IsValid() override;
|
|
|
|
EProtocolStackCreateType eType;
|
|
bool bDead {};
|
|
|
|
bool bStreamReaderFlagAdhocRead {};
|
|
bool bStreamReaderFlagAdhocPump {};
|
|
|
|
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;
|
|
|
|
AuSPtr<IStreamReader> pStreamReaderAsInputSource;
|
|
AuUInt uPreferredFragmentSize {};
|
|
|
|
SpecialReader readView;
|
|
SpecialWriter writeView;
|
|
|
|
AuRenterableMutex mutex;
|
|
|
|
void DiscardAllocCaches();
|
|
};
|
|
} |