Robot Devastation
InputManager.hpp
1 // Authors: see AUTHORS.md at project root.
2 // CopyPolicy: released under the terms of the LGPLv2.1, see LICENSE at project root.
3 // URL: https://github.com/asrob-uc3m/robotDevastation
4 
5 #ifndef __RD_INPUT_MANAGER_HPP__
6 #define __RD_INPUT_MANAGER_HPP__
7 
8 #include <string>
9 #include <vector>
10 #include <map>
11 
12 #include "InputEventListener.hpp"
13 
14 namespace rd{
15 
36 {
37  public:
38  //------------------------------ Construction & destruction ---------------------------------------------------//
44  static InputManager * getInputManager();
45 
51  static InputManager * getInputManager(const std::string & id);
52 
54  static bool destroyInputManager();
55 
56  virtual ~InputManager();
57 
58 
59  //------------------------------ Manager Startup & Halting ----------------------------------------------------//
65  virtual bool start() = 0;
66 
68  virtual bool stop() = 0;
69 
71  virtual bool isStopped() const = 0;
72 
73  //------------------------------ Configuration & Listeners ----------------------------------------------------//
75  bool addInputEventListener( InputEventListener * listener );
76 
79 
81  virtual bool configure(const std::string & parameter, const std::string & value);
82 
83  //------------------------------ Input Manager API ------------------------------------------------------------//
85  virtual bool refreshEvents();
86 
87  protected:
92  static bool Register( InputManager * manager, const std::string & id);
93 
95  std::vector<InputEventListener *> listeners;
96 
97  private:
100 
102  static std::string currentId;
103 
105  static std::map< std::string, InputManager * > inputManagerRegistry;
106 
107 };
108 
109 }
110 
111 #endif //-- __RD_INPUT_MANAGER_HPP__
rd::InputManager::isStopped
virtual bool isStopped() const =0
True if the manager is not active.
rd
The main, catch-all namespace for Robot Devastation.
Definition: groups.dox:4
rd::InputManager::stop
virtual bool stop()=0
Stop capturing input events.
rd::InputManager::currentId
static std::string currentId
Stores the id of the current unique instance used.
Definition: InputManager.hpp:102
rd::InputManager::configure
virtual bool configure(const std::string &parameter, const std::string &value)
Configures a parameter with a value.
Definition: InputManager.cpp:107
rd::InputEventListener
Interface for objects that can be notified of input events by the InputManager.
Definition: InputEventListener.hpp:20
rd::InputManager::listeners
std::vector< InputEventListener * > listeners
Observers registered to be notified of input events.
Definition: InputManager.hpp:95
rd::InputManager::getInputManager
static InputManager * getInputManager()
Get a reference to the InputManager.
Definition: InputManager.cpp:17
rd::InputManager::start
virtual bool start()=0
Start to capture input events.
rd::InputManager
User input manager (keyboard, mouse, joysticks, etc)
Definition: InputManager.hpp:35
rd::InputManager::refreshEvents
virtual bool refreshEvents()
Get system info about input events.
Definition: InputManager.cpp:112
rd::InputManager::addInputEventListener
bool addInputEventListener(InputEventListener *listener)
Adds a InputEventListener to the list of observers to be notified of events.
Definition: InputManager.cpp:95
rd::InputManager::inputManagerRegistry
static std::map< std::string, InputManager * > inputManagerRegistry
Stores all the InputManager that have been registered.
Definition: InputManager.hpp:105
rd::InputManager::destroyInputManager
static bool destroyInputManager()
Deallocate all the registered InputManager.
Definition: InputManager.cpp:54
rd::InputManager::removeInputEventListeners
bool removeInputEventListeners()
Unregisters all the InputEventListener stored.
Definition: InputManager.cpp:101
rd::InputManager::Register
static bool Register(InputManager *manager, const std::string &id)
This function allows subclasses to install their unique instances in the singleton register to be sel...
Definition: InputManager.cpp:117
rd::InputManager::inputManagerInstance
static InputManager * inputManagerInstance
Stores the unique instance of the InputManager.
Definition: InputManager.hpp:99