AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
isobus::CANMessageDataCallback Class Reference

A class that represents data of a CAN message by using a callback function. More...

#include <can_message_data.hpp>

Inheritance diagram for isobus::CANMessageDataCallback:
[legend]
Collaboration diagram for isobus::CANMessageDataCallback:
[legend]

Public Member Functions

 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::size_t size () const override
 Get the size of the data.
 
std::uint8_t get_byte (std::size_t index) override
 Get the byte at the given index.
 
std::unique_ptr< CANMessageDatacopy_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.
 
- Public Member Functions inherited from isobus::CANMessageData
virtual ~CANMessageData ()=default
 Default destructor.
 

Private Attributes

std::size_t totalSize
 The total size of the data.
 
DataChunkCallback callback
 The callback function to be called for each data chunk.
 
void * parentPointer
 The parent object that gets passed to the callback function.
 
std::vector< std::uint8_t > buffer
 The buffer to store the data chunks.
 
std::size_t bufferSize
 The size of the buffer.
 
std::size_t dataOffset = 0
 The offset of the data in the buffer.
 
bool initialized = false
 Whether the buffer has been initialized.
 

Detailed Description

A class that represents data of a CAN message by using a callback function.

Definition at line 119 of file can_message_data.hpp.

Constructor & Destructor Documentation

◆ CANMessageDataCallback()

isobus::CANMessageDataCallback::CANMessageDataCallback ( std::size_t size,
DataChunkCallback callback,
void * parentPointer = nullptr,
std::size_t chunkSize = 7 )

Constructor for transport data that uses a callback function.

Parameters
[in]sizeThe size of the data.
[in]callbackThe callback function to be called for each data chunk.
[in]parentPointerThe parent object that owns this callback (optional).
[in]chunkSizeThe size of each data chunk (optional, default is 7).

Definition at line 83 of file can_message_data.cpp.

Member Function Documentation

◆ copy_if_not_owned()

std::unique_ptr< CANMessageData > isobus::CANMessageDataCallback::copy_if_not_owned ( std::unique_ptr< CANMessageData > self) const
overridevirtual

If the data isn't owned by this class, make a copy of the data.

Parameters
[in]selfA pointer to this object.
Returns
A copy of the data if it isn't owned by this class, otherwise it returns itself.

Implements isobus::CANMessageData.

Definition at line 116 of file can_message_data.cpp.

◆ get_byte()

std::uint8_t isobus::CANMessageDataCallback::get_byte ( std::size_t index)
overridevirtual

Get the byte at the given index.

Parameters
[in]indexThe index of the byte to get.
Returns
The byte at the given index.

Implements isobus::CANMessageData.

Definition at line 100 of file can_message_data.cpp.

◆ size()

std::size_t isobus::CANMessageDataCallback::size ( ) const
overridevirtual

Get the size of the data.

Returns
The size of the data.

Implements isobus::CANMessageData.

Definition at line 95 of file can_message_data.cpp.

Member Data Documentation

◆ buffer

std::vector<std::uint8_t> isobus::CANMessageDataCallback::buffer
private

The buffer to store the data chunks.

Definition at line 150 of file can_message_data.hpp.

◆ bufferSize

std::size_t isobus::CANMessageDataCallback::bufferSize
private

The size of the buffer.

Definition at line 151 of file can_message_data.hpp.

◆ callback

DataChunkCallback isobus::CANMessageDataCallback::callback
private

The callback function to be called for each data chunk.

Definition at line 148 of file can_message_data.hpp.

◆ dataOffset

std::size_t isobus::CANMessageDataCallback::dataOffset = 0
private

The offset of the data in the buffer.

Definition at line 152 of file can_message_data.hpp.

◆ initialized

bool isobus::CANMessageDataCallback::initialized = false
private

Whether the buffer has been initialized.

Definition at line 153 of file can_message_data.hpp.

◆ parentPointer

void* isobus::CANMessageDataCallback::parentPointer
private

The parent object that gets passed to the callback function.

Definition at line 149 of file can_message_data.hpp.

◆ totalSize

std::size_t isobus::CANMessageDataCallback::totalSize
private

The total size of the data.

Definition at line 147 of file can_message_data.hpp.


The documentation for this class was generated from the following files: