2022-08-28 19:02:06 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
2022-12-12 23:50:05 +00:00
|
|
|
File: AuProtocolStack.hpp
|
2022-08-28 19:02:06 +00:00
|
|
|
Date: 2022-8-24
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
2023-04-25 11:13:16 +00:00
|
|
|
#include "../AuIOPipeProcessor.hpp"
|
|
|
|
|
2022-08-28 19:02:06 +00:00
|
|
|
namespace Aurora::IO::Protocol
|
|
|
|
{
|
|
|
|
struct ProtocolPiece;
|
|
|
|
|
2023-04-28 01:41:45 +00:00
|
|
|
struct ProtocolStack : IProtocolStack,
|
|
|
|
AuEnableSharedFromThis<ProtocolStack>
|
2022-08-28 19:02:06 +00:00
|
|
|
{
|
|
|
|
~ProtocolStack();
|
|
|
|
|
2023-06-04 18:02:33 +00:00
|
|
|
void Terminate();
|
2023-04-25 11:13:16 +00:00
|
|
|
bool DoTick() override;
|
2022-08-28 19:02:06 +00:00
|
|
|
bool DoTick(const AuSPtr<AuByteBuffer> &read, const AuSPtr<ProtocolPiece> &pPiece);
|
|
|
|
|
2022-09-29 10:45:08 +00:00
|
|
|
AuSPtr<IProtocolPiece> AppendInterceptor(const AuSPtr<IProtocolInterceptor> &pInterceptor, AuUInt uOutputBufferSize) override;
|
|
|
|
AuSPtr<IProtocolPiece> AppendInterceptorEx(const AuSPtr<IProtocolInterceptorEx> &pInterceptor, AuUInt uOutputBufferSize) override;
|
2022-11-08 19:24:08 +00:00
|
|
|
AuSPtr<IProtocolPiece> AppendSingleFrameProcessor(const AuSPtr<IProtocolInterceptorEx> &pInterceptorEx) override;
|
|
|
|
AuSPtr<IProtocolPiece> AppendSingleFrameProcessorEx(const AuSPtr<IProtocolInterceptorEx> &pInterceptorEx, AuUInt uOutputBufferSize) override;
|
2023-04-28 01:41:45 +00:00
|
|
|
|
2022-09-29 10:45:08 +00:00
|
|
|
AuSPtr<IProtocolPiece> PrependInterceptor(const AuSPtr<IProtocolInterceptor> &pInterceptor, AuUInt uOutputBufferSize) override;
|
|
|
|
AuSPtr<IProtocolPiece> PrependInterceptorEx(const AuSPtr<IProtocolInterceptorEx> &pInterceptor, AuUInt uOutputBufferSize) override;
|
2023-04-28 01:41:45 +00:00
|
|
|
AuSPtr<IProtocolPiece> PrependSingleFrameProcessor(const AuSPtr<IProtocolInterceptorEx> &pInterceptorEx) override;
|
|
|
|
AuSPtr<IProtocolPiece> PrependSingleFrameProcessorEx(const AuSPtr<IProtocolInterceptorEx> &pInterceptorEx, AuUInt uOutputBufferSize) override;
|
|
|
|
|
2022-09-29 10:45:08 +00:00
|
|
|
AuSPtr<IProtocolPiece> AddEndInterceptor(const AuSPtr<IProtocolInterceptorEx> &pInterceptor) override;
|
2022-08-28 19:02:06 +00:00
|
|
|
|
|
|
|
void Destroy() override;
|
|
|
|
|
2022-12-12 23:50:05 +00:00
|
|
|
AuSPtr<IProtocolPiece> AddInterceptorWhere(bool bPrepend, const AuSPtr<IProtocolInterceptor> &pInterceptor, AuUInt uOutputBufferSize);
|
|
|
|
AuSPtr<IProtocolPiece> AddInterceptorWhereEx(bool bPrepend, const AuSPtr<IProtocolInterceptorEx> &pInterceptor, AuUInt uOutputBufferSize, bool bMultipleTick);
|
2022-09-04 00:16:49 +00:00
|
|
|
|
2022-08-28 19:02:06 +00:00
|
|
|
AuSPtr<IStreamWriter> AsStreamWriter() override;
|
|
|
|
AuSPtr<Memory::ByteBuffer> AsWritableByteBuffer() override;
|
|
|
|
|
|
|
|
AuSPtr<IStreamReader> AsStreamReader() override;
|
|
|
|
AuSPtr<Memory::ByteBuffer> AsReadableByteBuffer() override;
|
|
|
|
|
2023-04-28 01:41:45 +00:00
|
|
|
AuList<AuSPtr<IProtocolPiece>> GetArrayOfInterceptors() override;
|
|
|
|
AuSPtr<IProtocolPiece> GetInterceptorAtIndex(AuUInt32 uIndex) override;
|
|
|
|
|
2022-08-28 19:02:06 +00:00
|
|
|
AuSPtr<AuByteBuffer> pSourceBufer;
|
|
|
|
bool bOwnsSource {};
|
|
|
|
|
|
|
|
AuSPtr<AuByteBuffer> pDrainBuffer;
|
|
|
|
|
|
|
|
AuSPtr<ProtocolPiece> pBottomPiece;
|
|
|
|
AuSPtr<ProtocolPiece> pTopPiece;
|
2022-09-02 19:53:25 +00:00
|
|
|
|
|
|
|
bool bWrittenEnd {};
|
2023-04-25 11:13:16 +00:00
|
|
|
|
|
|
|
AuWPtr<AuIO::IOPipeWork> pPipeWork;
|
2023-04-25 11:57:02 +00:00
|
|
|
bool bKillPipeOnFirstRootLevelFalse {};
|
2023-04-26 06:37:14 +00:00
|
|
|
|
|
|
|
AuSPtr<IStreamReader> pStreamReaderCache;
|
|
|
|
AuSPtr<IStreamWriter> pStreamWriterCache;
|
2023-06-11 14:09:07 +00:00
|
|
|
|
|
|
|
void DiscardAllocCaches();
|
2022-08-28 19:02:06 +00:00
|
|
|
};
|
|
|
|
}
|