-
Notifications
You must be signed in to change notification settings - Fork 14
Replace GetComponent macro with function #721
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
Conversation
|
I have a general question. Why do we need macros for injector? What is the critical improvement it gives us that we should go with the macro and preprocessor logic over simple C++ syntax? What if we had a class, let's say pseudo code: class Application {
public:
Application() {
m_state_register = new StateRegisterImpl();
m_state_processor = new StateRegisterImpl(m_state_register);
// ...
}
~Application() {
delete m_state_processor;
delete m_state_register;
}
StateRegister GetStateRegister() { return m_state_register; }
StateProcessor GetStateProcessor() { return m_state_processor; }
private:
StateRegister *m_state_register;
StateProcessor *m_state_register;
}I see that with macro we don't need to write initializer, deinitializer and getter methods so it's an improvement. But having a bit of boilerplate (we don't create new components often, and at the code review we can check that they are initialized properly), we would have a simple C++ syntax. Then we don't need templated |
|
Can you please open an issue about this if you feel strongly about this instead of polluting pull requests with your agenda? |
|
Thank you for the thumbs up, despite my rude tone. I copied the comment to an issue and commented there: #723 |
Gnappuraz
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.
utACK 6764600
@castarco is that a thumbs up or a thumbs down or a I don't know, I'm undecided?
I looked at #726. What I like about my version better is that if you do |
Yes, until we have runtime-only container for holding components, it's a runtime check. Basically, what I don't like in this PR is a nullptr-casting magic, especially on the API level (see gathering Settings in the walletextention). |
AM5800
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.
That API is not exactly public. I can make it private and befriend
Happens all the time, you weren't exactly bothered by this in
I don't get that and I'm not sure I want that. |
|
Another thing I like better in here is that getting a component is constant, whereas in #726 needs to look it up in a tree map. |
6764600 to
9569d3d
Compare
Thanks :-) – There's a detailed discussion also about this whole thing in #723, feel free to chime in there! |
I complained about the first version where Get(T*) was a public API. Now it looks great. |
frolosofsky
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.
utACK 77f0ca1
Signed-off-by: Julian Fleischer <[email protected]>
Signed-off-by: Julian Fleischer <[email protected]>
Signed-off-by: Julian Fleischer <[email protected]>
Signed-off-by: Julian Fleischer <[email protected]>
Signed-off-by: Julian Fleischer <[email protected]>
aecc5cc to
420d86f
Compare
Signed-off-by: Julian Fleischer <[email protected]>
Fixes #618
Further refactorings possible would be to not have the NAME be required when defining a component. That's left for some upcoming weekends side projects ;-)
Signed-off-by: Julian Fleischer [email protected]