17#include <peak/dll_interface/peak_dll_interface_util.hpp>
18#include <peak/error_handling/peak_error_handling.hpp>
43 ,
public std::enable_shared_from_this<Port>
64 std::string
ID()
const;
75 std::string
Name()
const;
111 std::string
TLType()
const;
197 std::vector<uint8_t>
Read(uint64_t address,
size_t numBytes)
const;
212 void Write(uint64_t address,
const std::vector<uint8_t>& bytes)
const;
224 std::vector<std::shared_ptr<PortURL>>
URLs()
const;
227 friend class ClassCreator<
Port>;
231 void Initialize()
const override;
232 mutable std::vector<std::shared_ptr<PortURL>> m_portURLs;
248 : m_backendHandle(portHandle)
253 return QueryRawInformationFromCInterfaceFunction([&](int32_t* dataType, uint8_t* buffer,
size_t* bufferSize) {
260 return QueryStringFromCInterfaceFunction(
266 return QueryStringFromCInterfaceFunction([&](
char* name,
size_t* nameSize) {
273 return QueryStringFromCInterfaceFunction([&](
char* vendorName,
size_t* vendorNameSize) {
280 return QueryStringFromCInterfaceFunction([&](
char* modelName,
size_t* modelNameSize) {
287 return QueryStringFromCInterfaceFunction([&](
char* version,
size_t* versionSize) {
294 return QueryStringFromCInterfaceFunction([&](
char* tlType,
size_t* tlTypeSize) {
301 return QueryStringFromCInterfaceFunction([&](
char* moduleName,
size_t* moduleNameSize) {
309 QueryNumericFromCInterfaceFunction<PEAK_ENDIANNESS>([&](
PEAK_ENDIANNESS* dataEndianness) {
316 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isReadable) {
323 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isWritable) {
330 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isAvailable) {
337 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isImplemented) {
342inline std::vector<uint8_t>
Port::Read(uint64_t address,
size_t numBytes)
const
344 std::vector<uint8_t> bytes(numBytes);
345 ExecuteAndMapReturnCodes(
351inline void Port::Write(uint64_t address,
const std::vector<uint8_t>& bytes)
const
353 ExecuteAndMapReturnCodes(
357inline std::vector<std::shared_ptr<PortURL>>
Port::URLs()
const
359 InitializeIfNecessary();
363inline void Port::Initialize()
const
365 auto numUrls = QueryNumericFromCInterfaceFunction<size_t>(
368 std::vector<std::shared_ptr<PortURL>> urls;
369 for (
size_t x = 0; x < numUrls; ++x)
371 auto portUrlHandle = QueryNumericFromCInterfaceFunction<PEAK_PORT_URL_HANDLE>(
377 std::make_shared<ClassCreator<PortURL>>(portUrlHandle, std::const_pointer_cast<Port>(shared_from_this())));
Represents a GenTL port.
Definition peak_port.hpp:44
RawInformation Info(int32_t infoCommand) const
Delivers information based on the given GenTL info command.
Definition peak_port.hpp:251
Port(const class Port &other)=delete
std::vector< std::shared_ptr< PortURL > > URLs() const
Returns the URLs.
Definition peak_port.hpp:357
bool IsAvailable() const
Checks whether the port is available.
Definition peak_port.hpp:328
std::string Name() const
Returns the name.
Definition peak_port.hpp:264
std::string ModelName() const
Returns the model name.
Definition peak_port.hpp:278
void Write(uint64_t address, const std::vector< uint8_t > &bytes) const
Writes a given amount of bytes at a given address.
Definition peak_port.hpp:351
std::string TLType() const
Returns the TL (transport layer) type.
Definition peak_port.hpp:292
std::string ID() const
Returns the ID.
Definition peak_port.hpp:258
std::string Version() const
Returns the version.
Definition peak_port.hpp:285
bool IsImplemented() const
Checks whether the port is implemented.
Definition peak_port.hpp:335
std::string ModuleName() const
Returns the module name.
Definition peak_port.hpp:299
Port & operator=(class Port &&other)=delete
bool IsWritable() const
Checks whether the port is writable.
Definition peak_port.hpp:321
std::string VendorName() const
Returns the vendor name.
Definition peak_port.hpp:271
Endianness DataEndianness() const
Returns the data endianness.
Definition peak_port.hpp:306
Port(class Port &&other)=delete
Port & operator=(const class Port &other)=delete
bool IsReadable() const
Checks whether the port is readable.
Definition peak_port.hpp:314
std::vector< uint8_t > Read(uint64_t address, size_t numBytes) const
Reads a given amount of bytes at a given address.
Definition peak_port.hpp:342
Endianness
Endianness of pixel data in a Buffer or the data in a Port.
Definition peak_common_enums.hpp:28
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:32
PEAK_C_API PEAK_Port_GetDataEndianness(PEAK_PORT_HANDLE portHandle, PEAK_ENDIANNESS *dataEndianness)
Asks the given port for its data endianness.
PEAK_C_API PEAK_Port_Read(PEAK_PORT_HANDLE portHandle, uint64_t address, uint8_t *bytesToRead, size_t bytesToReadSize)
Tells the given port to read the given amount of bytes at the given address.
PEAK_C_API PEAK_Port_GetName(PEAK_PORT_HANDLE portHandle, char *name, size_t *nameSize)
Asks the given port for its name.
PEAK_C_API PEAK_Port_GetID(PEAK_PORT_HANDLE portHandle, char *id, size_t *idSize)
Asks the given port for its ID.
struct PEAK_PORT_URL * PEAK_PORT_URL_HANDLE
Definition peak_backend.h:455
PEAK_C_API PEAK_Port_GetVersion(PEAK_PORT_HANDLE portHandle, char *version, size_t *versionSize)
Asks the given port for its version.
PEAK_C_API PEAK_Port_GetIsAvailable(PEAK_PORT_HANDLE portHandle, PEAK_BOOL8 *isAvailable)
Asks the given port whether it is available.
struct PEAK_PORT * PEAK_PORT_HANDLE
Definition peak_backend.h:451
PEAK_C_API PEAK_Port_GetIsImplemented(PEAK_PORT_HANDLE portHandle, PEAK_BOOL8 *isImplemented)
Asks the given port whether it is implemented.
PEAK_C_API PEAK_Port_GetNumURLs(PEAK_PORT_HANDLE portHandle, size_t *numUrls)
Asks the given port for its number of URLs.
PEAK_C_API PEAK_Port_GetTLType(PEAK_PORT_HANDLE portHandle, char *tlType, size_t *tlTypeSize)
Asks the given port for its TL type.
PEAK_C_API PEAK_Port_GetIsReadable(PEAK_PORT_HANDLE portHandle, PEAK_BOOL8 *isReadable)
Asks the given port whether it is readable.
PEAK_C_API PEAK_Port_GetInfo(PEAK_PORT_HANDLE portHandle, int32_t infoCommand, int32_t *infoDataType, uint8_t *info, size_t *infoSize)
Asks the given port for an information based on a specific command.
PEAK_C_API PEAK_Port_GetModelName(PEAK_PORT_HANDLE portHandle, char *modelName, size_t *modelNameSize)
Asks the given port for its model name.
int8_t PEAK_BOOL8
Definition peak_backend.h:26
int32_t PEAK_ENDIANNESS
Definition peak_backend.h:155
PEAK_C_API PEAK_Port_GetVendorName(PEAK_PORT_HANDLE portHandle, char *vendorName, size_t *vendorNameSize)
Asks the given port for its vendor name.
PEAK_C_API PEAK_Port_Write(PEAK_PORT_HANDLE portHandle, uint64_t address, const uint8_t *bytesToWrite, size_t bytesToWriteSize)
Tells the given port to write the given amount of bytes at the given address.
PEAK_C_API PEAK_Port_GetIsWritable(PEAK_PORT_HANDLE portHandle, PEAK_BOOL8 *isWritable)
Asks the given port whether it is writable.
PEAK_C_API PEAK_Port_GetURL(PEAK_PORT_HANDLE portHandle, size_t index, PEAK_PORT_URL_HANDLE *portUrlHandle)
Asks the given port for the URL with the given index.
PEAK_C_API PEAK_Port_GetModuleName(PEAK_PORT_HANDLE portHandle, char *moduleName, size_t *moduleNameSize)
Asks the given port for its module name.
#define PEAK_C_ABI_PREFIX
Definition peak_dll_defines.h:16