Basically, it looks something like this:
class i_Input : public i_Component{ public: //classes class i_Event { //... }; typedef boost::iterator_range >::const_iterator> t_ConstEventRange; typedef boost::iterator_range >::const_iterator> t_EventRange; public: //functions virtual t_ConstEventRange Events() const = 0; virtual t_EventRange Events() = 0;};
The Direct Input component that implements the i_Input interface has an implementation of those two functions that looks like this (where mEvents is a std::vector >):
i_Input::t_ConstEventRange c_DirectInput::Events() const{ return boost::make_iterator_range(mEvents.begin(), mEvents.end());}i_Input::t_EventRange c_DirectInput::Events(){ return boost::make_iterator_range(mEvents.begin(), mEvents.end());}
Using this would then look like the following, regardless of whether I use std::vector or std::list or some custom wrapper (if all my assumptions are correct; I haven't test it yet, though):
//mInput is of type boost::shared_ptri_Input::t_ConstEventRange events = mInput->Events();i_Input::t_ConstEventRange::const_iterator eventIterator;for (eventIterator = events.begin(); eventIterator != events.end(); ++eventIterator){ //examine and handle the event}
I also added to the Startup State class, so that it actually initializes an input component with a Direct Input instance, and finds the primary keyboard, mouse, and joystick, to be passed on to other states once all the other necessary components are also initialized.
Next up is deciding what I want to do with making an Ogre component. After that will be CEGUI, and I should at that point be able to add a few more states (menu states) and see something again, though it won't look any different than my previous prototype. But I think the code and design should be somewhat cleaner.