cmil::SDL::SDLTranslator Class Reference

Translates SDL events to InputData for the InputArbitrator. More...

#include <SDLTranslator.h>

Inheritance diagram for cmil::SDL::SDLTranslator:

Inheritance graph
[legend]
Collaboration diagram for cmil::SDL::SDLTranslator:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::list< DeviceTranslator * > DeviceTranslators

Public Member Functions

 SDLTranslator (System *const sys)
virtual bool addTranslated (DeviceTranslator *sdl_device)
DeviceRegistrygetDevices ()
 This provides a temporary device registry which containes the devices which the SDL translator can provide.
virtual void poll ()
virtual void translate (const SDL_Event &input_event)
virtual ~SDLTranslator ()
std::string getName () const

Private Attributes

DeviceRegistry m_devices
 This registry contains the devices provided by this translator.
DeviceTranslators m_sdltranslators
 This contains a list of sdl devices.
SDL_Event m_event

Detailed Description

Translates SDL events to InputData for the InputArbitrator.

Definition at line 290 of file SDLTranslator.h.


Member Typedef Documentation

typedef std::list<DeviceTranslator*> cmil::SDL::SDLTranslator::DeviceTranslators

Definition at line 295 of file SDLTranslator.h.


Constructor & Destructor Documentation

cmil::SDL::SDLTranslator::SDLTranslator ( System *const   sys  )  [inline]

Definition at line 293 of file SDLTranslator.h.

00293 : SystemClient(sys) {} 

virtual cmil::SDL::SDLTranslator::~SDLTranslator (  )  [inline, virtual]

Definition at line 306 of file SDLTranslator.h.

References Logger::log_debug(), and m_sdltranslators.

00306                                  {
00307           log_debug("dtor");
00308           for(DeviceTranslators::iterator i = m_sdltranslators.begin(); i != m_sdltranslators.end() ; ++i)
00309             if(*i) { 
00310               log_debug("dtor : deleting device translator");
00311               delete (*i); 
00312             }
00313         }

Here is the call graph for this function:


Member Function Documentation

bool cmil::SDL::SDLTranslator::addTranslated ( DeviceTranslator sdl_device  )  [virtual]

Definition at line 684 of file SDLTranslator.cpp.

References cmil::SDL::DeviceTranslator::getDevices(), Logger::log_error(), m_devices, m_sdltranslators, and cmil::DeviceRegistry::mergeRegistry().

Referenced by cmil::SDL::SDLSystem::init().

00684                                                                   {
00685       for(DeviceTranslators::iterator i= m_sdltranslators.begin(); i != m_sdltranslators.end() ; i++) 
00686         if(*(*i) == *sdl_device) {
00687           log_error("addTranslated() Prevented due to name conflict with pre-existing device translator.");
00688           delete sdl_device;
00689           return false;
00690         }
00691 
00692       m_sdltranslators.push_back(sdl_device);
00693 
00695       m_devices.mergeRegistry(sdl_device->getDevices());
00696       return true;
00697     } 

Here is the call graph for this function:

Here is the caller graph for this function:

DeviceRegistry & cmil::SDL::SDLTranslator::getDevices (  )  [virtual]

This provides a temporary device registry which containes the devices which the SDL translator can provide.

Implements cmil::InputTranslator.

Definition at line 716 of file SDLTranslator.cpp.

References m_devices.

Referenced by cmil::SDL::SDLSystem::init().

00716                                               {
00717       return m_devices;
00718     };

Here is the caller graph for this function:

std::string cmil::SDL::SDLTranslator::getName (  )  const [inline, virtual]

Implements cmil::InputTranslator.

Definition at line 316 of file SDLTranslator.h.

00316 { return "SDLTranslator"; }

void cmil::SDL::SDLTranslator::poll (  )  [virtual]

Implements cmil::InputTranslator.

Definition at line 710 of file SDLTranslator.cpp.

References m_event, and translate().

Referenced by cmil::SDL::SDLSystem::poll().

00710                              {
00711       while(SDL_PollEvent(&m_event)) {
00712         translate(m_event); 
00713       }
00714     };

Here is the call graph for this function:

Here is the caller graph for this function:

void cmil::SDL::SDLTranslator::translate ( const SDL_Event &  input_event  )  [virtual]

Definition at line 699 of file SDLTranslator.cpp.

References m_sdltranslators, and cmil::SystemClient::quit().

Referenced by poll().

00699                                                               {
00700         if(input_event.type == SDL_QUIT) 
00701           quit();
00702         else {
00704           for(DeviceTranslators::iterator i = m_sdltranslators.begin(); i != m_sdltranslators.end() ; i++)
00705             if((*i)->translate(input_event))
00706              continue;
00707         }
00708     };

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

DeviceRegistry cmil::SDL::SDLTranslator::m_devices [private]

This registry contains the devices provided by this translator.

Definition at line 321 of file SDLTranslator.h.

Referenced by addTranslated(), and getDevices().

SDL_Event cmil::SDL::SDLTranslator::m_event [private]

Definition at line 326 of file SDLTranslator.h.

Referenced by poll().

DeviceTranslators cmil::SDL::SDLTranslator::m_sdltranslators [private]

This contains a list of sdl devices.

Definition at line 324 of file SDLTranslator.h.

Referenced by addTranslated(), translate(), and ~SDLTranslator().


The documentation for this class was generated from the following files:
(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