Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes

input::Device< DeviceEvent > Class Template Reference

Device base class. More...

#include <_src_input_device.hh>

List of all members.

Public Types

typedef
base::Event::ListenerFunctor 
ListenerFunctor

Public Member Functions

bool Enable (const bool enable=true)
bool IfEnabled (void) const
void Enqueue (const DeviceEvent &event)
bool PeekQueue (DeviceEvent &event) const
bool Dequeue (DeviceEvent &event)
uint QueueSize (void) const
void SetQueueOverflow (const uint overflow)
void RegisterListener (shptr< ListenerFunctor > listener)
void UnregisterListener (shptr< ListenerFunctor > listener)

Protected Member Functions

 Device (void)
virtual ~Device ()
virtual bool EnableDevice (void)=0

Private Types

typedef std::deque< DeviceEvent > Queue

Private Member Functions

void VentQueue (void)

Private Attributes

bool mEnabledLogical
 if device and input queue are both enabled
bool mEnabledDevice
 if EnableDevice() succeeded (assigned only once)
bool mTriedToEnableDevice
 if tried to call EnableDevice()
Queue mQueue
 queue of events
uint mQueueOverflow
 vent if more than this many events
base::Event mBroadcaster
 object used to broadcast input events to listeners

Detailed Description

template<class DeviceEvent>
class input::Device< DeviceEvent >

Device base class.

A concrete Device class will consist of:

All Devices shall be initially disabled to let program become ready.

Implementation:


Member Typedef Documentation

template<class DeviceEvent>
typedef base::Event ::ListenerFunctor input::Device< DeviceEvent >::ListenerFunctor
template<class DeviceEvent>
typedef std::deque<DeviceEvent> input::Device< DeviceEvent >::Queue [private]

Constructor & Destructor Documentation

template<class DeviceEvent >
input::Device< DeviceEvent >::Device ( void   )  [protected]

ctor/dtor.

template<class DeviceEvent >
input::Device< DeviceEvent >::~Device (  )  [protected, virtual]

Member Function Documentation

template<class DeviceEvent>
bool input::Device< DeviceEvent >::Dequeue ( DeviceEvent &  event  ) 

Dequeue next event.

Returns:
False if no more events (or disabled).
template<class DeviceEvent >
bool input::Device< DeviceEvent >::Enable ( const bool  enable = true  ) 

Template Method pattern.

Returns:
Try to enable device, return true if enabled.
template<class DeviceEvent>
virtual bool input::Device< DeviceEvent >::EnableDevice ( void   )  [protected, pure virtual]
template<class DeviceEvent>
void input::Device< DeviceEvent >::Enqueue ( const DeviceEvent &  event  ) 

Enqueue an event.

template<class DeviceEvent >
bool input::Device< DeviceEvent >::IfEnabled ( void   )  const
Returns:
True if device is enabled.
template<class DeviceEvent>
bool input::Device< DeviceEvent >::PeekQueue ( DeviceEvent &  event  )  const

Peek next event without dequeueing it.

Returns:
False if no more events (or disabled).
template<class DeviceEvent >
uint input::Device< DeviceEvent >::QueueSize ( void   )  const
Returns:
Amount of events in a queue.
template<class DeviceEvent >
void input::Device< DeviceEvent >::RegisterListener ( shptr< ListenerFunctor listener  ) 

Register functor to be called when an event is enqueued.

template<class DeviceEvent >
void input::Device< DeviceEvent >::SetQueueOverflow ( const uint  overflow  ) 

Set the maximum amount of events that can be queued at one time. 0 : disable overflowing

template<class DeviceEvent >
void input::Device< DeviceEvent >::UnregisterListener ( shptr< ListenerFunctor listener  ) 

Unregister listener.

template<class DeviceEvent >
void input::Device< DeviceEvent >::VentQueue ( void   )  [private]

Begin dropping events if queue is overflowing. The joystick is more prone to causing this problem than the keyboard.


Member Data Documentation

template<class DeviceEvent>
base::Event input::Device< DeviceEvent >::mBroadcaster [private]

object used to broadcast input events to listeners

template<class DeviceEvent>
bool input::Device< DeviceEvent >::mEnabledDevice [private]

if EnableDevice() succeeded (assigned only once)

template<class DeviceEvent>
bool input::Device< DeviceEvent >::mEnabledLogical [private]

if device and input queue are both enabled

template<class DeviceEvent>
Queue input::Device< DeviceEvent >::mQueue [private]

queue of events

template<class DeviceEvent>
uint input::Device< DeviceEvent >::mQueueOverflow [private]

vent if more than this many events

template<class DeviceEvent>
bool input::Device< DeviceEvent >::mTriedToEnableDevice [private]

if tried to call EnableDevice()


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Palomino Flight Simulator documents generated by doxygen 1.7.1 on Tue May 15 2012 22:40:11