InputHandler.h

Go to the documentation of this file.
00001 
00005 /* Copyright © 2009, 2010 James Legg.
00006     This program is free software: you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation, either version 3 of the License, or
00009     (at your option) any later version.
00010 */
00011 #ifndef INPUTHANDLER_H_
00012 #define INPUTHANDLER_H_
00013 
00014 #include <set>
00015 #include <vector>
00016 #include "InputDevice.h"
00017 #include "Scene.h"
00018 
00019 namespace Engine
00020 {
00021 class InputDeviceKeyboard;
00022 class InputDeviceJoystick;
00025 class InputHandler
00026 {
00027 public:
00028     class iterator
00029         :   public std::set<InputDevice *>::iterator
00030     {
00031         public:
00032             iterator (const std::set<InputDevice *>::iterator & other)
00033                 :   std::set<InputDevice *>::iterator(other)
00034             {
00035             }
00036             iterator ()
00037                 :   std::set<InputDevice *>::iterator()
00038             {
00039             }
00040             bool operator <(const iterator & other) const
00041             {
00042                 return **this < *other;
00043             }
00044     };
00045     
00046     virtual ~InputHandler();
00047     static InputHandler & get_instance();
00048     void set_scene(Scene & scene);
00049     void poll();
00050     
00052     iterator begin();
00054     iterator end();
00055     
00057     std::size_t get_number_of_devices() const;
00058     
00064     iterator add_device(InputDevice & device);
00067     void remove_device(InputDevice & device);
00070     void remove_device(iterator it);
00071 private:    
00072     // We only want one InputHandler. Use get_instance to get it.
00073     InputHandler();
00075     void init();
00076     
00077     std::set<InputDevice *> devices;
00078     
00079     // The scene to send notifications to.
00080     Scene * scene;
00081     // devices which always exist
00082     InputDeviceKeyboard * keyboard;
00083     
00085     std::vector<InputDeviceJoystick *> joysticks;
00086 };
00087 
00088 }
00089 
00090 #endif /*INPUTHANDLER_H_*/

Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:12 2010 by Doxygen version 1.4.7 for Racer version svn335.