[+] ProtocolPiece::GetParent

This commit is contained in:
Reece Wilson 2023-06-04 19:07:26 +01:00
parent c9ed4b09b9
commit bc203d8cbc
3 changed files with 28 additions and 0 deletions

View File

@ -9,8 +9,16 @@
namespace Aurora::IO::Protocol
{
struct ProtocolStack;
struct IProtocolPiece
{
/**
* @brief
* @return
*/
virtual AuSPtr<ProtocolStack> GetParent() = 0;
/**
* @brief
* @return

View File

@ -10,8 +10,24 @@
#include "AuProtocolStack.hpp"
#include "IProtocolNext.hpp"
// TODO: check correct thread or throw api
// restrict this to one thread
namespace Aurora::IO::Protocol
{
AuSPtr<ProtocolStack> ProtocolPiece::GetParent()
{
if (this->pParent)
{
return this->pParent->SharedFromThis();
}
else
{
return {};
}
}
AuSPtr<IStreamWriter> ProtocolPiece::ToNextWriter()
{
if (!this->pParent)
@ -62,6 +78,7 @@ namespace Aurora::IO::Protocol
void ProtocolPiece::Remove()
{
this->PrivateUserDataClear();
if (!this->pParent)
{
return;
@ -100,6 +117,8 @@ namespace Aurora::IO::Protocol
this->pParent->pBottomPiece = this->pNext;
}
this->PrivateUserDataClear();
this->pParent = nullptr;
}

View File

@ -24,6 +24,7 @@ namespace Aurora::IO::Protocol
bool bMultipleTick {};
AuSPtr<ProtocolStack> GetParent() override;
AuSPtr<IProtocolPiece> GetNextPiece() override;
bool ReallocateDrainBuffer(AuUInt32 uOutputLength) override;
void Remove() override;