Represents a data reader/writer to a caller. More...
#include <Adapter_FrontEndClass.h>
Public Types | |
enum | MemoryBlockNumber { Memory_Block_0 = 0 , Memory_Block_1 = 1 , Memory_Block_2 = 2 } |
Represents the memory blocks that can be accessed. Hides how memory blocks are actually identified. More... | |
Public Member Functions | |
DataReaderWriter (MemoryBlockNumber blockNumber) | |
Constructor. | |
~DataReaderWriter () | |
Destructor. | |
uint32_t | GetMemoryBlockByteSize () |
Retrieve the size of the currently opened memory block in bytes. | |
ByteArray | Read (int byteOffset, uint32_t maxBytes) |
Read a specified number of bytes. | |
void | Write (int byteOffset, const ByteArray &data, uint32_t maxBytes) |
Write a specified number of bytes. | |
std::string | BufferToString (const ByteArray &data, uint32_t maxBytes, int indent) |
Convert the specified data up to the specified number of bytes into a string by performing a "hex dump" on the data. | |
Private Member Functions | |
const char * | _GetBlockNameForBlockNumber (DataReaderWriter::MemoryBlockNumber blockNumber) |
Given a block number, retrieve the corresponding block name. | |
Private Attributes | |
bool | _initialized |
int | _dataHandle |
uint32_t | _memoryBlockByteSize |
Represents a data reader/writer to a caller.
Wraps the Adapter_BackEnd dynamic library.
Definition at line 73 of file Adapter_FrontEndClass.h.
enum MemoryBlockNumber |
Represents the memory blocks that can be accessed. Hides how memory blocks are actually identified.
Enumerator | |
---|---|
Memory_Block_0 | First block. |
Memory_Block_1 | Second block. |
Memory_Block_2 | Third block. |
Definition at line 80 of file Adapter_FrontEndClass.h.
DataReaderWriter | ( | MemoryBlockNumber | blockNumber | ) |
Constructor.
blockNumber | A value from the MemoryBlockNumber enumeration indicating which memory block to access. |
Definition at line 118 of file Adapter_FrontEndClass.cpp.
References DataReaderWriter::_dataHandle, DataReaderWriter::_GetBlockNameForBlockNumber(), DataReaderWriter::_initialized, DataReaderWriter::_memoryBlockByteSize, DDR_ErrorCode_Success, DDR_GetMemorySize(), and DDR_OpenMemoryBlock().
~DataReaderWriter | ( | ) |
Destructor.
Definition at line 152 of file Adapter_FrontEndClass.cpp.
References DataReaderWriter::_dataHandle, DataReaderWriter::_initialized, and DDR_CloseMemoryBlock().
|
private |
Given a block number, retrieve the corresponding block name.
blockNumber | A value from the MemoryBlockNumber enumeration indicating the block of memory to open. |
Definition at line 89 of file Adapter_FrontEndClass.cpp.
References BLOCK_NAME_0, BLOCK_NAME_1, BLOCK_NAME_2, DataReaderWriter::Memory_Block_0, DataReaderWriter::Memory_Block_1, and DataReaderWriter::Memory_Block_2.
Referenced by DataReaderWriter::__enter__(), and DataReaderWriter::DataReaderWriter().
std::string BufferToString | ( | const ByteArray & | data, |
uint32_t | maxBytes, | ||
int | indent | ||
) |
Convert the specified data up to the specified number of bytes into a string by performing a "hex dump" on the data.
data | The data to process. |
maxBytes | The number of bytes from the data to process. |
indent | Number of spaces to indent each line. |
Definition at line 313 of file Adapter_FrontEndClass.cpp.
References Helpers::formatstring().
Referenced by DesignPatternExamples_cpp::Adapter_Exercise().
uint32_t GetMemoryBlockByteSize | ( | ) |
Retrieve the size of the currently opened memory block in bytes.
Definition at line 164 of file Adapter_FrontEndClass.cpp.
References DataReaderWriter::_initialized, and DataReaderWriter::_memoryBlockByteSize.
Referenced by DesignPatternExamples_cpp::Adapter_Exercise().
ByteArray Read | ( | int | byteOffset, |
uint32_t | maxBytes | ||
) |
Read a specified number of bytes.
byteOffset | Byte offset into the memory block from which to start reading. |
maxBytes | Number of bytes to read |
DataReaderWriterInitException | Data reader/writer not initialized. |
DataReaderWriterException | Failed to read data. |
Definition at line 172 of file Adapter_FrontEndClass.cpp.
References DataReaderWriter::_dataHandle, DataReaderWriter::_initialized, DDR_ErrorCode_Success, DDR_GetDataChunk(), and DDR_MAX_OFFSET.
Referenced by DesignPatternExamples_cpp::Adapter_Exercise().
void Write | ( | int | byteOffset, |
const ByteArray & | data, | ||
uint32_t | maxBytes | ||
) |
Write a specified number of bytes.
byteOffset | Byte offset into the memory block to which to start writing. |
data | Array of bytes to write. Must be at least 'maxBytes' in length. |
maxBytes | Number of bytes to write |
DataReaderWriterInitException | Data reader/writer not initialized. |
DataReaderWriterException | Failed to write data. |
Definition at line 236 of file Adapter_FrontEndClass.cpp.
References DataReaderWriter::_dataHandle, DataReaderWriter::_initialized, DDR_ErrorCode_Success, DDR_GetDataChunk(), DDR_MAX_OFFSET, and DDR_SetDataChunk().
Referenced by DesignPatternExamples_cpp::Adapter_Exercise().
|
private |
Definition at line 89 of file Adapter_FrontEndClass.h.
Referenced by DataReaderWriter::__enter__(), DataReaderWriter::__exit__(), DataReaderWriter::DataReaderWriter(), DataReaderWriter::Read(), DataReaderWriter::Write(), and DataReaderWriter::~DataReaderWriter().
|
private |
Definition at line 88 of file Adapter_FrontEndClass.h.
Referenced by DataReaderWriter::__enter__(), DataReaderWriter::__exit__(), DataReaderWriter::DataReaderWriter(), DataReaderWriter::GetMemoryBlockByteSize(), DataReaderWriter::MemoryBlockByteSize(), DataReaderWriter::Read(), DataReaderWriter::Write(), and DataReaderWriter::~DataReaderWriter().
|
private |
Definition at line 90 of file Adapter_FrontEndClass.h.
Referenced by DataReaderWriter::__enter__(), DataReaderWriter::DataReaderWriter(), DataReaderWriter::GetMemoryBlockByteSize(), and DataReaderWriter::MemoryBlockByteSize().