10#ifndef CAN_MESSAGE_DATA_HPP
11#define CAN_MESSAGE_DATA_HPP
16#include "isobus/utility/data_span.hpp"
33 virtual std::size_t
size()
const = 0;
38 virtual std::uint8_t
get_byte(std::size_t index) = 0;
43 virtual std::unique_ptr<CANMessageData>
copy_if_not_owned(std::unique_ptr<CANMessageData> self)
const = 0;
48 ,
public std::vector<std::uint8_t>
66 std::size_t
size()
const override;
71 std::uint8_t
get_byte(std::size_t index)
override;
76 void set_byte(std::size_t index, std::uint8_t value);
85 std::unique_ptr<CANMessageData>
copy_if_not_owned(std::unique_ptr<CANMessageData> self)
const override;
101 std::size_t
size()
const override;
106 std::uint8_t
get_byte(std::size_t index)
override;
115 std::unique_ptr<CANMessageData>
copy_if_not_owned(std::unique_ptr<CANMessageData> self)
const override;
130 std::size_t chunkSize = 7);
134 std::size_t
size()
const override;
139 std::uint8_t
get_byte(std::size_t index)
override;
144 std::unique_ptr<CANMessageData>
copy_if_not_owned(std::unique_ptr<CANMessageData> self)
const override;
An object to represent common callbacks used within this CAN stack.
Defines a base class to represent a generic ISOBUS control function.
An abstraction of a CAN message, could be > 8 data bytes.
A class that represents data of a CAN message by using a callback function.
std::size_t dataOffset
The offset of the data in the buffer.
bool initialized
Whether the buffer has been initialized.
std::size_t bufferSize
The size of the buffer.
std::size_t size() const override
Get the size of the data.
CANMessageDataCallback(std::size_t size, DataChunkCallback callback, void *parentPointer=nullptr, std::size_t chunkSize=7)
Constructor for transport data that uses a callback function.
std::uint8_t get_byte(std::size_t index) override
Get the byte at the given index.
std::vector< std::uint8_t > buffer
The buffer to store the data chunks.
DataChunkCallback callback
The callback function to be called for each data chunk.
std::size_t totalSize
The total size of the data.
void * parentPointer
The parent object that gets passed to the callback function.
std::unique_ptr< CANMessageData > copy_if_not_owned(std::unique_ptr< CANMessageData > self) const override
If the data isn't owned by this class, make a copy of the data.
A class that represents data of a CAN message by holding a vector of bytes.
CANMessageDataVector(std::size_t size)
Construct a new CANMessageDataVector object.
std::size_t size() const override
Get the size of the data.
std::unique_ptr< CANMessageData > copy_if_not_owned(std::unique_ptr< CANMessageData > self) const override
If the data isn't owned by this class, make a copy of the data.
CANDataSpan data() const
Get the data span.
void set_byte(std::size_t index, std::uint8_t value)
Set the byte at the given index.
std::uint8_t get_byte(std::size_t index) override
Get the byte at the given index.
A class that represents data of a CAN message by holding a view of an array of bytes....
CANMessageDataView(const std::uint8_t *ptr, std::size_t len)
Construct a new CANMessageDataView object.
std::uint8_t get_byte(std::size_t index) override
Get the byte at the given index.
std::unique_ptr< CANMessageData > copy_if_not_owned(std::unique_ptr< CANMessageData > self) const override
If the data isn't owned by this class, make a copy of the data.
CANDataSpan data() const
Get the data span.
std::size_t size() const override
Get the size of the data.
A interface class that represents data payload of a CAN message of arbitrary length.
virtual std::unique_ptr< CANMessageData > copy_if_not_owned(std::unique_ptr< CANMessageData > self) const =0
If the data isn't owned by this class, make a copy of the data.
virtual ~CANMessageData()=default
Default destructor.
virtual std::uint8_t get_byte(std::size_t index)=0
Get the byte at the given index.
virtual std::size_t size() const =0
Get the size of the data.
This namespace encompasses all of the ISO11783 stack's functionality to reduce global namespace pollu...
DataSpan< const std::uint8_t > CANDataSpan
A read-only span of data for a CAN message.
bool(*)(std::uint32_t callbackIndex, std::uint32_t bytesOffset, std::uint32_t numberOfBytesNeeded, std::uint8_t *chunkBuffer, void *parentPointer) DataChunkCallback
A callback to get chunks of data for transfer by a protocol.