Skip to main content
gamedev.net
🔒 Locked

Runtime type information???

Started by LuNo 3 replies 250+ views
Original Post
LuNo
LuNo
I have a manager class which holds all GUI components in my engine. All GUI components are derived from GUIBase. The manager class contains an array of GUIBase pointers to all GUI components. The rendering object is supposed to iterate through this array and draw the components according to what kind of object it finds. Is there a fast approach for identifying what kind of object the GUIBase pointer is pointing to? I know of the typeid() macro, but I''m pretty sure this will slow down the engine. PS. Notice that I have put all my drawing code into a render object. I did this for the sake of good OO design, but I''m not so sure about the decision anymore. If I put a virtual function draw() in GUIBase, the sub-classes could override, and this whole mess would be avoided. Thoughts?
fup
fup
If you want to stick with your first methodology (why do you think that it''s better than the second?) you can eliminate the need for type checking with the ''Visitor'' design pattern.

Unfortunately it''s not something I can describe adequately in just a few sentences and I don''t know of any good online sources for you to read about it. Does anyone else know of any URLs that describe this pattern?




ai-junkie.com
Qw3r7yU10p!
Qw3r7yU10p!
wiki?

[edited by - petewood on March 10, 2003 12:27:50 PM]
LuNo
LuNo
Thanks alot... I''ll look into it

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.