devicesbus read data
This commit is contained in:
36
src/message_bus/pipeline/PayloadRef.h
Normal file
36
src/message_bus/pipeline/PayloadRef.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include <QMetaType>
|
||||
|
||||
#include "core/memory/MemoryPool.h"
|
||||
|
||||
namespace softbus::message_bus::pipeline
|
||||
{
|
||||
|
||||
struct PayloadRef
|
||||
{
|
||||
softbus::core::memory::MemoryPool::BlockPtr block;
|
||||
std::size_t offset{0};
|
||||
std::size_t length{0};
|
||||
|
||||
const std::uint8_t* bytes() const
|
||||
{
|
||||
if (!block || !block->data || offset > block->capacity) {
|
||||
return nullptr;
|
||||
}
|
||||
return block->data + offset;
|
||||
}
|
||||
|
||||
bool valid() const
|
||||
{
|
||||
return block && block->data && (offset + length <= block->capacity);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace softbus::message_bus::pipeline
|
||||
|
||||
Q_DECLARE_METATYPE(softbus::message_bus::pipeline::PayloadRef)
|
||||
Reference in New Issue
Block a user