Page 2 of 2
Re: Messaging/Event System (Idea... Critique?)
Posted: Mon Oct 04, 2010 6:51 pm
by LeonBlade
I remember when I hit 666... I made a thread about it... haha.
http://elysianshadows.com/phpBB3/viewto ... f=4&t=4617
Re: Messaging/Event System (Idea... Critique?)
Posted: Tue Oct 05, 2010 9:55 am
by ismetteren
XianForce wrote:Well, shouldn't you just have each Event, have an event data structure associated with it? You shouldn't have to back track that way...
Like the event would consist of a type, and data (the data being specific to the event type), and then when the listener receives it, whatever object that wants to handle it, will handle it...
Unless you mean TYPE cast and not BACK cast... Back cast is what threw me off :/
Sorry, i mean type casting... i was sure that, when you where casting from a supertype to a subtype it was called backcasting, and was special in that you had to use dynamic_cast. But after having searched for it on google, there seem to be no such thing.. maybe you will have to use dynamic_cast anyway??
Now i'm all confused about C++ casting :S
Re: Messaging/Event System (Idea... Critique?)
Posted: Thu Oct 07, 2010 11:00 am
by qpHalcy0n
That's called downcasting. Going the other way is upcasting.
You don't HAVE to use dynamic_cast. You can use a regular typecast, however the dynamic_cast checks type at runtime and incurs some overhead and will throw a null reference or runtime exception if the types are incompatible.
Re: Messaging/Event System (Idea... Critique?)
Posted: Thu Oct 07, 2010 1:27 pm
by ismetteren
qpHalcy0n wrote:That's called downcasting. Going the other way is upcasting.
You don't HAVE to use dynamic_cast. You can use a regular typecast, however the dynamic_cast checks type at runtime and incurs some overhead and will throw a null reference or runtime exception if the types are incompatible.
Oh, i must have mixed down and back up. Thank you