Jump to content
  • Advertisement
Sign in to follow this  
Bombshell93

Type checking, is there another way?

This topic is 2392 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a message class, it contains a reference to the sending object, it is intended to be inherited from by all other message types so they may hold relevant information.
The message is sent to the entity manager, which will send it to all entities, who will do what they like with the information carried by the message depending on what message it is and then send it to all components where the .
I'm unsure on how I should approach this.
my original idea was to use a single message class with an enum containing its message type and pointing to an object holding the relevant information. Problem with that is between the library and the program it would be quite messy and hard to work with as you can't extend an enum, and working with numbers directly would be a nightmare to keep track of.

So now, to my knowledge to keep it flexible and easy to work with I'm stuck with a master message and a bunch of children,
of which I assume casting into types and null checking to be my only option.

if anyone knows of any better ways to approach this any and all help is appreciated,
Thanks in advanced,
Bombshell

Share this post


Link to post
Share on other sites
Advertisement
How about one of the incarnations of the observer pattern? e.g. signals and slots (see boost, Qt, gtkmm, etc).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!