blob: 02c40e4ab16543ef9020e67ba763c806bef4c7a2 [file] [log] [blame]
Narumol Prangnawarat404b2752019-09-24 17:23:16 +01001//
2// Copyright © 2019 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
Matteo Martincigh2ffcc412019-11-05 11:47:40 +00008#include <memory>
9
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000010namespace arm
Narumol Prangnawarat404b2752019-09-24 17:23:16 +010011{
12
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000013namespace pipe
Narumol Prangnawarat404b2752019-09-24 17:23:16 +010014{
15
16class IReadOnlyPacketBuffer // interface used by the read thread
17{
18public:
19 virtual ~IReadOnlyPacketBuffer() {}
20
Matteo Martincigh76c50d82019-11-21 12:10:42 +000021 virtual const unsigned char* GetReadableData() const = 0;
Narumol Prangnawarat404b2752019-09-24 17:23:16 +010022
23 virtual unsigned int GetSize() const = 0;
24
25 virtual void MarkRead() = 0;
26};
27
28class IPacketBuffer : public IReadOnlyPacketBuffer // interface used by code that writes binary packets
29{
30public:
31 virtual ~IPacketBuffer() {}
32
33 virtual void Commit(unsigned int size) = 0;
34
35 virtual void Release() = 0;
36
37 virtual unsigned char* GetWritableData() = 0;
Jim Flynn0204f092020-06-22 20:41:43 +010038
39 /// release the memory held and reset internal point to null.
40 /// After this function is invoked the PacketBuffer is unusable.
41 virtual void Destroy() = 0;
Narumol Prangnawarat404b2752019-09-24 17:23:16 +010042};
43
Matteo Martincigh2ffcc412019-11-05 11:47:40 +000044using IPacketBufferPtr = std::unique_ptr<IPacketBuffer>;
45
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000046} // namespace pipe
Narumol Prangnawarat404b2752019-09-24 17:23:16 +010047
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000048} // namespace arm