You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
BTW, are you aware that build 1325 introduced pointers to functions?
Is that make any difference in applying triangular communication?
MQL5: Added support for pointers to functions to simplify the arrangement of event models.
To declare a pointer to a function, specify the "pointer to a function" type, for example:
Now, TFunc is a type, and it is possible to declare the variable pointer to the function:
The func_ptr variable may store the function address to declare it later:
Pointers to functions can be stored and passed as parameters. You cannot get a pointer to a non-static class method.
probably is just for MT5, and from what I've seen it's still not for methods, just functions.
Anyhow I still don't get how do you define the third party ability within the base class, for instance in the context of trend line and container, where is the 3rd object.
But I'll try to read again.
I mean, how and where to decide who (what class) will get what (event).
It's clear that the top dispatcher, the language native one, i.e. the language ::OnChartEvent is written just once in a project, at the top level class.
Then from here, what is the correct way or ways of dispatching events to different objects?
Should there be a dispatching event class? Should it be done just in the ::OnChartEvent based on if statements?
What I seem to lack in understanding of the events model in conjuction with OO and MQL5, is what is the right kind of dispatching the events.
I mean, how and where to decide who (what class) will get what (event).
It's clear that the top dispatcher, the language native one, i.e. the language ::OnChartEvent is written just once in a project, at the top level class.
Then from here, what is the correct way or ways of dispatching events to different objects?
Should there be a dispatching event class? Should it be done just in the ::OnChartEvent based on if statements?
ok, I think I got it. There is a real problem of concept shifting when you come from procedural to oop.
Actually, I once wanted to implement the observer and because of lack of interfaces in MQL or multiple inheritence I did not. Did not think about your good idea that the same object can force the interface on both sides.
so actually each CObject now has a place of one object which is the reciever of events, and also has a registration method for the listening object to subscribe as such and an event sender method and an event handler method used by the reciever.
Actually, I once wanted to implement the observer and because of lack of interfaces in MQL or multiple inheritence I did not. Did not think about your good idea that the same object can force the interface on both sides.
Just to encourage you, I have been using listeners a lot with MQL4.
Thanks, but I'm not feeling encouraged (:
I managed to do it, but not with a contract between the publisher and listener, I mean, the publisher had to assume that the listener has the handling method, but nothing forced that it has.
Or, I would have to inherit all listeners from a main listener object - but then of course I would lose all point because they can't inherit other classes.
Anyhow, I'm a pro at programming but definetly not in OO where I lack experience as of yet, and I am not competing with any of you experienced oo programmers like Doerk.
What I come to know is that being procedural gives you good logic and programming skills but the shift is mentally hard, specially if a procedural oriented like me faces the mission of building OO framework, it is a totally different state of mind. And the GUI part framework is the most detailed framework with many events to take care of, I think you guys will agree that among frameworks it is the hardest to build.