-
Notifications
You must be signed in to change notification settings - Fork 0
Implement plugin subsystem #16
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
base: master
Are you sure you want to change the base?
Conversation
ad60aa5 to
d268e3e
Compare
d268e3e to
c5532f9
Compare
|
I suggest you to implement PluginAPI as an interface class to avoid C-style type erasure |
203ce34 to
3bb586c
Compare
|
In general, design looks nice to me (seems like an Observer pattern). But there is some noticeable point about extensibility: events list could be extended & each event can accept different arguments (types & amount). Also, you need to somehow distinguish events with identical call signatures (e.g. memwrite & memread events arguments would be the same) |
|
For example, try to define two events with identical argument list, and two events with different arguments list. Hope this helps to prototype generic solution |
|
Example event notification (approximate syntax): event_model.call<MemWrite>(core, ptr, size); |
derzhavin3016
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments, it's not required to be fixed since they're absolutely minor. It's more like a notice
|
|
||
| private: | ||
| std::unique_ptr<void, DlCloser> m_handle; | ||
| static_assert(sizeof(m_handle) == sizeof(void *)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, it is not required by standard
| void attach(IEventConsumerHandle consumer) { | ||
| m_consumers.push_back(std::move(consumer)); | ||
| } | ||
| void detach(IEventConsumerHandle consumer) { m_consumers.remove(consumer); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused a bit with thus function. How could you remove plugin by address, if you've lost it after attach() call?
e.g.:
EventManager ev;
auto consumer = std::make_unique<IntConsumer>(42);
ev.attach(std::move(consumer));
// consumer is in moved-from state hereafter
ev.detach(???); // what to pass here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused a bit with thus function. How could you remove plugin by address, if you've lost it after
attach()call? e.g.:EventManager ev; auto consumer = std::make_unique<IntConsumer>(42); ev.attach(std::move(consumer)); // consumer is in moved-from state hereafter ev.detach(???); // what to pass here?
is detach necessary at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this method
|
After personal discussion, it was decided to leave implementation in current state, with optional code deduplication via defines/Jinja codegen. The last part is to add Unit tests, after which this PR could be merged |


Implement plugin subsystem:
Plugin subsystem consist of following parts:
Plugin manager(that manages plugins and notify them on events)

Plugin(manages dynamically loaded plugin)
loadPlugin function that returns LoadablePlugin struct with pointers to notify, unload and plugin internal memory.
I need help deciding on the notify function signature. I think it’s worth making a function for each event (due to the fact that the parameters will be different for different events).