![]() |
IDS peak genericC++ v1.11.0
|
The FileAdapter is a utility class designed for accessing files stored in a RemoteDevice's persistent memory. More...
#include <peak/file/peak_fileadapter.hpp>
Public Member Functions | |
| FileAdapter (const std::shared_ptr< NodeMap > &nodeMap, const std::string &fileName) | |
| Constructs a FileAdapter for a specific file name in the RemoteDevice's NodeMap. | |
| ~FileAdapter () | |
| FileAdapter (const FileAdapter &other)=delete | |
| FileAdapter & | operator= (const FileAdapter &other)=delete |
| FileAdapter (FileAdapter &&other)=delete | |
| FileAdapter & | operator= (FileAdapter &&other)=delete |
| PEAK_NO_DISCARD std::vector< uint8_t > | Read (uint64_t size, uint64_t offset=0) const |
| Returns the contents of the file that the adapter references. | |
| uint64_t | Read (uint8_t *buffer, uint64_t size, uint64_t offset=0) const |
| Reads the contents of the file into the supplied buffer. | |
| void | Write (const std::vector< uint8_t > &data, uint64_t offset=0) const |
| Writes the data to the file the adapter references. | |
| void | Write (const uint8_t *buffer, uint64_t bufferSize, uint64_t offset=0) const |
| Writes the data supplied in the buffer to the file the adapter references. | |
| void | Delete () const |
| Deletes the file the adapter references. | |
| PEAK_NO_DISCARD uint64_t | Size () const |
| Returns the content size of the file the adapter references. This is the maximum size that can be read. | |
| PEAK_NO_DISCARD uint64_t | MaxSize () const |
| Returns the maximum size of the file the adapter references. This is the maximum size that can be written. | |
Static Public Member Functions | |
| static PEAK_NO_DISCARD std::vector< std::string > | AvailableFileNames (const std::shared_ptr< NodeMap > &nodeMap) |
| Returns a vector of available file names from the given NodeMap. File names may vary depending on the device. | |
The FileAdapter is a utility class designed for accessing files stored in a RemoteDevice's persistent memory.
It provides convenient functions to Read, Write, and Delete files.
The FileAdapter class encapsulates the functions of the GenApi::FileProtocolAdapter.
|
inline |
Constructs a FileAdapter for a specific file name in the RemoteDevice's NodeMap.
File names may vary depending on the device. To obtain a list of valid file names, you can either iterate through the AvailableEntries of the 'FileSelector' EnumerationNode or use the static FileAdapter::AvailableFileNames function. Some files may be read-only.
Common file names include:
| nodeMap | The NodeMap of the RemoteDevice |
| fileName | A valid file name |
| InvalidArgumentException | The nodeMap pointer is invalid. |
| NotAvailableException | The 'FileSelector' node or it's entry with the given file name is not available. |
| InternalErrorException | An internal error has occurred. |
|
inline |
|
delete |
|
delete |
|
inlinestatic |
Returns a vector of available file names from the given NodeMap. File names may vary depending on the device.
| nodeMap | The NodeMap of the RemoteDevice |
| InvalidArgumentException | The NodeMap pointer is invalid. |
| NotAvailableException | The 'FileSelector' node is not available. |
| InternalErrorException | An internal error has occurred. |
|
inline |
Deletes the file the adapter references.
| InternalErrorException | An internal error has occurred. |
|
inline |
Returns the maximum size of the file the adapter references. This is the maximum size that can be written.
| InternalErrorException | An internal error has occurred. |
|
delete |
|
delete |
|
inline |
Returns the contents of the file that the adapter references.
To read the entire file, use FileAdapter::Size as the size argument.
Alternatively, you can specify an offset and a smaller size to read only a part of the file content.
| size | The amount of data to be read |
| offset | The position from the beginning of the file where data reading should start |
| OutOfRangeException | Size + offset exceeds the file's size. |
| InternalErrorException | An internal error has occurred. |
|
inline |
Reads the contents of the file into the supplied buffer.
To read the entire file, use FileAdapter::Size as the size argument.
Alternatively, you can specify an offset and a smaller size to read only a part of the file content.
| buffer | The buffer to write to. The buffer needs to be at least the size supplied in size. |
| size | The amount of data to be read |
| offset | The position from the beginning of the file where data reading should start |
| OutOfRangeException | Size + offset exceeds the file's size. |
| InternalErrorException | An internal error has occurred. |
|
inline |
Returns the content size of the file the adapter references. This is the maximum size that can be read.
| InternalErrorException | An internal error has occurred. |
|
inline |
Writes the data to the file the adapter references.
Ensure that the data size does not exceed FileAdapter::MaxSize.
| data | The data to be written |
| offset | The position from the beginning of the file where data writing should start |
| OutOfRangeException | Data size + offset exceeds the file's MaxSize or offset cannot be set. |
| InternalErrorException | An internal error has occurred. |
|
inline |
Writes the data supplied in the buffer to the file the adapter references.
Ensure that the data size does not exceed FileAdapter::MaxSize.
| buffer | The buffer containing the bytes to write to the file. |
| bufferSize | The size of the buffer supplied in buffer |
| offset | The position from the beginning of the file where data writing should start |
| OutOfRangeException | Data size + offset exceeds the file's MaxSize or offset cannot be set. |
| InternalErrorException | An internal error has occurred. |