2022-08-28 19:02:06 +00:00
|
|
|
/***
|
|
|
|
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
|
|
|
|
{
|
2022-09-02 19:53:25 +00:00
|
|
|
/**
|
|
|
|
* @brief
|
|
|
|
* @param pInterceptor
|
|
|
|
* @param uOutputBufferSize When 0, a hopefully not stupid default is used.
|
|
|
|
* @return
|
|
|
|
*/
|
2022-08-28 19:02:06 +00:00
|
|
|
virtual bool AddInterceptor(const AuSPtr<IProtocolInterceptor> &pInterceptor, AuUInt uOutputBufferSize) = 0;
|
2022-09-02 19:53:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief
|
|
|
|
* @param pInterceptor
|
|
|
|
* @param uOutputBufferSize When 0, a hopefully not stupid default is used.
|
|
|
|
* @return
|
|
|
|
*/
|
2022-08-28 19:02:06 +00:00
|
|
|
virtual bool AddInterceptorEx(const AuSPtr<IProtocolInterceptorEx> &pInterceptor, AuUInt uOutputBufferSize) = 0;
|
|
|
|
|
2022-09-02 19:53:25 +00:00
|
|
|
/**
|
|
|
|
* @brief
|
|
|
|
* @param pInterceptor
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
virtual bool 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.
|
|
|
|
*/
|
2022-08-28 19:02:06 +00:00
|
|
|
virtual void DoTick() = 0;
|
|
|
|
|
2022-09-02 19:53:25 +00:00
|
|
|
/**
|
|
|
|
* @brief
|
|
|
|
*/
|
2022-08-28 19:02:06 +00:00
|
|
|
virtual void Destroy() = 0;
|
|
|
|
};
|
|
|
|
|
2022-08-29 11:08:45 +00:00
|
|
|
/**
|
|
|
|
* @brief Allocates a new protocol stack with a buffered input stream of uLength bytes
|
|
|
|
* @param uLength
|
|
|
|
* @return
|
|
|
|
*/
|
2022-08-28 19:02:06 +00:00
|
|
|
AUKN_SYM AuSPtr<IProtocolStack> NewBufferedProtocolStack(AuUInt uLength);
|
2022-08-29 11:08:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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);
|
2022-08-28 19:02:06 +00:00
|
|
|
}
|