Sign in to follow this  
Sc4Freak

Engine design

Recommended Posts

Currently my engine is made up of a bunch of components - Renderer, Input Manager, Sound Manager, Interface Manager, etc. The implementation details of all these classes is hidden - encapsulated so the internals of the Renderer, for example, are not accessible to anything other than the Renderer. However, I see there might be a problem. My Sound Manager could access the Renderer and call ToggleWireframe(), if it really wanted to, and cause the entire frame to be renderered in wireframe. Or, my Renderer could access the Interface Manager and call CreateButton() and spawn buttons all over the screen for example. It seems to me that this shouldn't be allowed - where each class can arbitrarily access every other class's functionality. Should I bother to take steps to prevent this from happening? If so, how should I go about doing this?

Share this post


Link to post
Share on other sites
Don't go so mad.
in c++ you can do all kind of things, if you really want to.
so just use right engine design when all engine subsystem are independent from each other.

Share this post


Link to post
Share on other sites
I might have got your question wrong, but I believe that some encapsulation (data hiding) would help you out here.
Simply put your "hidden functions" under the private or protected keyword, that would assure you that only the class itself can use those functions.

EDIT:
Miss read, but how can another class use those functions if you're hiding them?
I think you'll have to explain the "if it really wanted to" statement.

Share this post


Link to post
Share on other sites
The only way an InputManager could call a function of a Renderer is if it has a reference to it, or the Renderer is some kind of global (or, *shudder*, a Singleton).

So ask yourself, why can my InputManager talk to my Renderer, and how can I rig it so that such communication is impossible.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this