AuroraRuntime/Include/Aurora/IO/Protocol/IProtocolStack.hpp
Reece Wilson 83ee24014f [+] IProtocolPiece (public interface)
[+] IProtocolPiece::Remove
[+] IProtocolPiece::ToNextWriter
[+] IProtocolPiece::GetNextPieceBuffer
2022-09-29 11:45:08 +01:00

84 lines
3.0 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: IProtocolStack.hpp
Date: 2022-8-24
Author: Reece
***/
#pragma once
namespace Aurora::IO::Protocol
{
struct IProtocolStack : IProtocolBaseReader, IProtocolBaseWriter
{
/**
* @brief
* @param pInterceptor
* @param uOutputBufferSize When 0, a hopefully not stupid default is used.
* @return
*/
virtual AuSPtr<IProtocolPiece> AppendInterceptor(const AuSPtr<IProtocolInterceptor> &pInterceptor, AuUInt uOutputBufferSize) = 0;
/**
* @brief Inserts the interceptor at the bottom of the protocol stack
* @param pInterceptor
* @param uOutputBufferSize When 0, a hopefully not stupid default is used.
* @return
*/
virtual AuSPtr<IProtocolPiece> PrependInterceptor(const AuSPtr<IProtocolInterceptor> &pInterceptor, AuUInt uOutputBufferSize) = 0;
/**
* @brief
* @param pInterceptorEx
* @param uOutputBufferSize When 0, a hopefully not stupid default is used.
* @return
*/
virtual AuSPtr<IProtocolPiece> AppendInterceptorEx(const AuSPtr<IProtocolInterceptorEx> &pInterceptorEx, AuUInt uOutputBufferSize) = 0;
/**
* @brief Inserts the interceptor at the bottom of the protocol stack
* @param pInterceptorEx
* @param uOutputBufferSize When 0, a hopefully not stupid default is used.
* @return
*/
virtual AuSPtr<IProtocolPiece> PrependInterceptorEx(const AuSPtr<IProtocolInterceptorEx> &pInterceptorEx, AuUInt uOutputBufferSize) = 0;
/**
* @brief
* @param pInterceptor
* @return
*/
virtual AuSPtr<IProtocolPiece> AddEndInterceptor(const AuSPtr<IProtocolInterceptorEx> &pInterceptor) = 0;
/**
* @brief Sends one down the protocol stack, regardless of how much data is written into the
* next piece/interceptor, and regardless of if another read tick is required.
* Latterly, you are responsible for consuming all available bytes in your interceptor.
*/
virtual void DoTick() = 0;
/**
* @brief
*/
virtual void Destroy() = 0;
};
/**
* @brief Allocates a new protocol stack with a buffered input stream of uLength bytes
* @param uLength
* @return
*/
AUKN_SYM AuSPtr<IProtocolStack> NewBufferedProtocolStack(AuUInt uLength);
/**
* @brief Creates a protocol stack backed by the memory of a pipe.
* DoTick must be called each time the pipe has data.
* The purpose of this function is not to provide utility in terms
* of ease of pipe usage, but rather, its' purpose is to provide
* functionality by removing a potential copy between pipe has-data
* and a buffered protocol stack.
* @param pWork
* @return
*/
AUKN_SYM AuSPtr<IProtocolStack> NewProtocolStackFromPipe(const AuSPtr<IIOPipeWork> &pWork);
}