Skip to content

Use std::function for callback #203

@ccvca

Description

@ccvca

As this library already requires C++ 14 , using std::function (https://en.cppreference.com/w/cpp/utility/functional/function) for the notifications should improve the usability a lot (e.g. bind to class members, use custom handler types, ...). As a function pointer can be bound to an std::function, too, this would not break existing code.

This would require changes in these places:

struct AdsNotification {

ADS/AdsLib/AdsDevice.cpp

Lines 83 to 87 in 3824918

AdsHandle AdsDevice::GetHandle(const uint32_t indexGroup,
const uint32_t indexOffset,
const AdsNotificationAttrib& notificationAttributes,
PAdsNotificationFuncEx callback,
const uint32_t hUser) const

long AdsSyncAddDeviceNotificationReqEx(long port,
const AmsAddr* pAddr,
uint32_t indexGroup,
uint32_t indexOffset,
const AdsNotificationAttrib* pAttrib,
PAdsNotificationFuncEx pFunc,
uint32_t hUser,
uint32_t* pNotification)

struct Notification {

PS: I'm aware that this is a feature request, but I just want to get a general opinion about this, before I potentially work on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions