Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call detector callbacks with a user-provided context #82

Closed
fmoessbauer opened this issue Nov 12, 2020 · 0 comments
Closed

call detector callbacks with a user-provided context #82

fmoessbauer opened this issue Nov 12, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@fmoessbauer
Copy link
Member

Currently the detector callback is initialized in Detector::init(argc, argv, callback), where callback is a c function pointer. The type of the callback is void (*)(const Race*). That does not allow to pass in a custom context which then can be used in the callback implementation.

Solution 1:
Instead, init could be extended with a new parameter context, and this context should be passed as second parameter to the callback function.

Solution 2:
As this is a C++ library anyways, we could instead use a functor (callable object) that internally contains the state. Here, it has to be considered that the init function uses virtual inheritance, hence the functor has to be virtual as well (as no templates can be used).

@fmoessbauer fmoessbauer added the enhancement New feature or request label Nov 12, 2020
fmoessbauer added a commit that referenced this issue Nov 13, 2020
This feature adds support to set a context in Detector::init that is
then passed to the on_race callbacks.

closes: #82
fmoessbauer added a commit that referenced this issue Nov 13, 2020
This feature adds support to set a context in Detector::init that is
then passed to the on_race callbacks.

closes: #82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant