I remember when I hit 666... I made a thread about it... haha.
http://elysianshadows.com/phpBB3/viewto ... f=4&t=4617
Messaging/Event System (Idea... Critique?)
Moderator: PC Supremacists
- LeonBlade
- Chaos Rift Demigod
- Posts: 1314
- Joined: Thu Jan 22, 2009 12:22 am
- Current Project: Trying to make my first engine in C++ using OGL
- Favorite Gaming Platforms: PS3
- Programming Language of Choice: C++
- Location: Blossvale, NY
Re: Messaging/Event System (Idea... Critique?)
There's no place like ~/
- ismetteren
- Chaos Rift Junior
- Posts: 276
- Joined: Mon Jul 21, 2008 4:13 pm
Re: Messaging/Event System (Idea... Critique?)
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??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 :/
Now i'm all confused about C++ casting :S
-
- Respected Programmer
- Posts: 387
- Joined: Fri Dec 19, 2008 3:33 pm
- Location: Dallas
- Contact:
Re: Messaging/Event System (Idea... Critique?)
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.
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.
- ismetteren
- Chaos Rift Junior
- Posts: 276
- Joined: Mon Jul 21, 2008 4:13 pm
Re: Messaging/Event System (Idea... Critique?)
Oh, i must have mixed down and back up. Thank youqpHalcy0n 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.