So I am writing a game engine that utilizes data driven design to instantiate various actors from xml files. I recently finished coding the event management system and everything fires off the events and the handlers catch them correctly. No easy task considering I used member function pointers and templates. The issue I am having now is that I would like to be able to do something like this in the xml file:
<InputComponent>
<Event EventName="GainedFocus" OnEvent="Initialize"/>
</InputComponent>
The problem should be pretty obvious. C++ has no form of reflection and therefore cannot, as far as I know, get the address for the Initialize function from the string "Initialize". This means that for slightly different input components I have derive from the class and register the events specific to that instance and add the functions. Also, it should be known that this is different than the way I am handling typical input:
<InputComponent>
<Mapping Type="MousePress" Button=1 Command="RotateCamera"/>
</InputComponent>
In this instance mapping is an element specific to input components and commands are themselves objects that are created with a factory. I cannot really do this with generic events though. Commands are specific items that perform the exact same operations on different objects whereas objects or components themselves often need to handle individual events differently. Has anyone done anything like this before? Genuinely curious as to how someone could go about doing something like this so that events that need to be registered to an object dont have to be hard coded into the class itself.
No comments:
Post a Comment