Class CMemBufferAccessorBase#
Defined in File mem_buffer_accessor.h
Nested Relationships#
Nested Types#
Inheritance Relationships#
Derived Types#
public CMemBufferAccessorRx
(Class CMemBufferAccessorRx)public CMemBufferAccessorTx
(Class CMemBufferAccessorTx)
Class Documentation#
-
class CMemBufferAccessorBase#
Memory buffer accessor.
Lock-free memory buffer accessor. This buffer allows the writing and reading of memory packets in a circular buffer.
Remark
This class doesn’t provide any handshaking. This is the task of the objects using this class.
- Attention
This class does not synchronize calls! It works if only one thread at the time writes data and only one thread at the time reads data. Reading and writing can occur simulateously.
- Attention
No protection is implemented to monitor the lifetime of the buffer. It is assumed that during any call this buffer is valid.
Subclassed by CMemBufferAccessorRx, CMemBufferAccessorTx
Public Functions
-
CMemBufferAccessorBase() = default#
Constructor.
-
virtual void Attach(uint8_t *pBuffer, uint32_t uiSize = 0)#
Attach the buffer to the accessor.
- Parameters:
pBuffer – [in] Pointer to the buffer that should be accessed.
uiSize – [in] Size of the buffer when still uninitialized (during buffer creation); otherwise 0.
-
virtual void Detach()#
Detach the buffer from the accessor.
-
bool IsValid() const#
Is valid.
- Returns:
Returns ‘true’ when valid; otherwise ‘false’.
-
const uint8_t *GetBufferPointer() const#
Get the buffer pointer.
- Returns:
Returns a pointer to the buffer or NULL when there is no buffer.
-
inline void ResetRx()#
Reset the Rx position to skip any sent data. Typically needed when a reconnect should take place.
-
inline void CancelSend()#
Cancel send operation.
-
inline bool Canceled() const#
Canceled?
- Returns:
Returns ‘true’ when the currend send job has been canceled; ‘false’ when not.
Protected Functions
-
SPacketHdr *GetPacketHdr(uint32_t uiPos) const#
Providing the position, return the packet header preceding the data.
- Parameters:
uiPos – [in] The position in the buffer
- Returns:
Pointer to the packet header or NULL when the position isn’t within the buffer.
-
uint8_t *GetPacketData(uint32_t uiPos) const#
Providing the position, return the packet data following the header.
- Parameters:
uiPos – [in] The position in the buffer
- Returns:
Pointer to the packet data or NULL when the position isn’t within the buffer.
-
inline virtual bool HasUnreadData() const#
Has unread data.
- Returns:
Returns ‘true’ when unread data is still available; otherwise returns ‘false’.
-
virtual void TriggerDataSend() = 0#
Trigger listener that a write operation was completed.
-
virtual bool WaitForData(uint32_t uiTimeoutMs) const = 0#
Wait for a write operation to be completed.
- Parameters:
uiTimeoutMs – [in] The amount of time (in ms) to wait for a trigger.
- Returns:
Returns ‘true’ when data was stored, ‘false’ when a timeout occurred.
-
virtual void TriggerDataReceive() = 0#
Trigger listener that a read operation was completed.
-
virtual bool WaitForFreeSpace(uint32_t uiTimeoutMs) const = 0#
Wait for a read operation to be completed.
- Parameters:
uiTimeoutMs – [in] The amount of time (in ms) to wait for a trigger.
- Returns:
Returns ‘true’ when data was stored, ‘false’ when a timeout occurred.
Protected Attributes
-
uint8_t *m_pBuffer = nullptr#
Buffer pointer.
-
SBufferHdr *m_pHdr = nullptr#
Buffer header.
-
bool m_bCancel = false#
Cancel the send operation.
-
struct SBufferHdr#
Memory buffer header.
Public Members
-
uint32_t uiVersion = SDVFrameworkInterfaceVersion#
Check for compatible communication channel.
-
uint32_t uiSize = 0u#
The size of the buffer.
-
uint32_t uiTxPos = 0u#
Current write position.
-
uint32_t uiRxPos = 0u#
Current read position.
-
uint32_t uiVersion = SDVFrameworkInterfaceVersion#
-
struct SPacketHdr#
Packet header.
The packet header is placed in front of every packet and describes the packet type as well as the size of the packet.
Remark
Packets are always starting at a 64-bit boundary.
Public Types
Public Members
-
enum CMemBufferAccessorBase::SPacketHdr::EType eType#
Packet type.
-
enum CMemBufferAccessorBase::SPacketHdr::EState eState#
The packet state.
-
uint32_t uiSize#
Packet size.
-
enum CMemBufferAccessorBase::SPacketHdr::EType eType#