Robot Devastation
MockInputEventListener.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_MOCK_INPUT_EVENT_LISTENER_HPP__
6 #define __RD_MOCK_INPUT_EVENT_LISTENER_HPP__
7 
8 #include <vector>
9 
10 #include "InputEventListener.hpp"
11 #include "Key.hpp"
12 #include "WindowEvent.hpp"
13 
14 namespace rd{
15 
22 {
23  public:
25 
26  virtual bool onKeyDown( const Key & k );
27  virtual bool onKeyUp( const Key & k );
28  virtual bool onWindowEvent( const WindowEvent & event );
29 
30  int getNumKeyDownPresses() const;
31  int getNumKeyUpPresses() const;
32  int getNumWindowEvents() const;
33 
34  bool clear();
35 
36  const std::vector<Key>& getStoredKeyUpPresses() const;
37  const std::vector<Key>& getStoredKeyDownPresses() const;
38  const std::vector<WindowEvent>& getStoredWindowEvents() const;
39 
40  private:
41  int num_keydown_presses;
42  std::vector<Key> stored_keydown_presses;
43 
44  int num_keyup_presses;
45  std::vector<Key> stored_keyup_presses;
46 
47  int num_window_events;
48  std::vector<WindowEvent> stored_window_events;
49 
50 };
51 }
52 #endif // __RD_MOCK_INPUT_EVENT_LISTENER_HPP__
rd
The main, catch-all namespace for Robot Devastation.
Definition: groups.dox:4
rd::MockInputEventListener
Mock object that receives and stores key presses, mainly for testing purposes.
Definition: MockInputEventListener.hpp:21
rd::MockInputEventListener::onWindowEvent
virtual bool onWindowEvent(const WindowEvent &event)
This function will be called whenever a window event is raised.
Definition: MockInputEventListener.cpp:30
rd::InputEventListener
Interface for objects that can be notified of input events by the InputManager.
Definition: InputEventListener.hpp:20
rd::Key
Class that represents a keyboard key.
Definition: Key.hpp:23
rd::WindowEvent
Class that represents a window event.
Definition: WindowEvent.hpp:19
rd::MockInputEventListener::onKeyUp
virtual bool onKeyUp(const Key &k)
This function will be called whenever a key is released on the keyboard.
Definition: MockInputEventListener.cpp:22
rd::MockInputEventListener::onKeyDown
virtual bool onKeyDown(const Key &k)
This function will be called whenever a key is pressed on the keyboard.
Definition: MockInputEventListener.cpp:14