cmil::SDL::tDeviceTranslator< DeviceBase > Class Template Reference

This class provides common concrete behavior for translators of a specific device type. More...

#include <SDLTranslator.h>

Inheritance diagram for cmil::SDL::tDeviceTranslator< DeviceBase >:

Inheritance graph
[legend]
Collaboration diagram for cmil::SDL::tDeviceTranslator< DeviceBase >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 tDeviceTranslator (System *const sys)
virtual bool translate (const SDL_Event &input_event)=0
 This should return a boolean as to whether or not translation was successful.
bool addCustomDevice (InputDevice *device)
virtual DeviceRegistrygetDevices ()=0
virtual std::string getName () const
unsigned long int getTimeRef () const

Protected Member Functions

virtual ~tDeviceTranslator ()

Protected Attributes

std::list< DeviceBase * > m_custom_devices

Friends

class SDLTranslator
 Class unallocation should only be handled by the SDLTranslator.

Detailed Description

template<typename DeviceBase>
class cmil::SDL::tDeviceTranslator< DeviceBase >

This class provides common concrete behavior for translators of a specific device type.

Definition at line 90 of file SDLTranslator.h.


Constructor & Destructor Documentation

template<typename DeviceBase>
cmil::SDL::tDeviceTranslator< DeviceBase >::tDeviceTranslator ( System *const   sys  )  [inline]

Definition at line 92 of file SDLTranslator.h.

00092 : DeviceTranslator(sys) {}; 

template<typename DeviceBase>
virtual cmil::SDL::tDeviceTranslator< DeviceBase >::~tDeviceTranslator (  )  [inline, protected, virtual]

Definition at line 134 of file SDLTranslator.h.

00134                                      {
00135           for(typename std::list<DeviceBase*>::iterator i = m_custom_devices.begin(); i != m_custom_devices.end() ; ++i) {
00136             if(*i) { (*i)->cleanup(); delete (*i); }
00137           }
00138         }


Member Function Documentation

template<typename DeviceBase>
bool cmil::SDL::tDeviceTranslator< DeviceBase >::addCustomDevice ( InputDevice device  )  [inline, virtual]

Implements cmil::SDL::DeviceTranslator.

Definition at line 96 of file SDLTranslator.h.

00096                                                   {
00097           DeviceBase* tmp_derived_ptr;
00098 
00099           if(!(tmp_derived_ptr= dynamic_cast<DeviceBase*>(device))) {
00100             log_error("addCustomDevice() not adding custom device due to cast check failure.");
00101             device->cleanup();
00102             delete device;
00103           }
00104           else {
00105             for(typename std::list<DeviceBase*>::iterator i = m_custom_devices.begin(); 
00106                 i != m_custom_devices.end() ; ++i)
00107               if(*(*i) == *tmp_derived_ptr) {
00108                 log_error("addCustomDevice() tried to add pre-existing controller type"); 
00109                 return false;
00110               }
00111 
00112             log_debug(std::string("addCustomDevice() adding device type with name: ").append(device->getName())); 
00113             m_custom_devices.push_back( tmp_derived_ptr);
00114             return true;
00115           }
00116 
00117           return false;
00118         } 

template<typename DeviceBase>
virtual DeviceRegistry& cmil::SDL::tDeviceTranslator< DeviceBase >::getDevices (  )  [pure virtual]

This retrieves a registry of devices provided by this translator, for instance, if there were only 1 joystick attached, it should return a registry containing just that joystick.

Implements cmil::SDL::DeviceTranslator.

Implemented in cmil::SDL::SDLKeyboards, cmil::SDL::SDLMice, and cmil::SDL::SDLControllers.

template<typename DeviceBase>
virtual std::string cmil::SDL::tDeviceTranslator< DeviceBase >::getName (  )  const [inline, virtual]

Implements cmil::SDL::DeviceTranslator.

Reimplemented in cmil::SDL::SDLKeyboards, cmil::SDL::SDLMice, and cmil::SDL::SDLControllers.

Definition at line 122 of file SDLTranslator.h.

00122                                           {
00123           return "tDeviceTranslator";
00124         }; 

template<typename DeviceBase>
unsigned long int cmil::SDL::tDeviceTranslator< DeviceBase >::getTimeRef (  )  const [inline, virtual]

Implements cmil::SDL::DeviceTranslator.

Definition at line 126 of file SDLTranslator.h.

00126                                              {
00127           return (unsigned long)SDL_GetTicks(); 
00128         } 

template<typename DeviceBase>
virtual bool cmil::SDL::tDeviceTranslator< DeviceBase >::translate ( const SDL_Event &  input_event  )  [pure virtual]

This should return a boolean as to whether or not translation was successful.

Implements cmil::SDL::DeviceTranslator.

Implemented in cmil::SDL::SDLKeyboards, cmil::SDL::SDLMice, and cmil::SDL::SDLControllers.


Friends And Related Function Documentation

template<typename DeviceBase>
friend class SDLTranslator [friend]

Class unallocation should only be handled by the SDLTranslator.

Definition at line 132 of file SDLTranslator.h.


Member Data Documentation

template<typename DeviceBase>
std::list<DeviceBase*> cmil::SDL::tDeviceTranslator< DeviceBase >::m_custom_devices [protected]

Definition at line 140 of file SDLTranslator.h.

Referenced by cmil::SDL::tDeviceTranslator< cmil::Mouse >::addCustomDevice(), cmil::SDL::SDLControllers::getDevices(), cmil::SDL::SDLMice::getDevices(), cmil::SDL::SDLKeyboards::getDevices(), and cmil::SDL::tDeviceTranslator< cmil::Mouse >::~tDeviceTranslator().


The documentation for this class was generated from the following file:
(c) 2006-2007 John P. Feltz
Generated on Wed Jul 25 16:08:03 2007 for Common Media Input Layer by doxygen 1.4.7

SourceForge.net Logo