00001 // ===================================================================================== 00002 // Filename: InputArbitrator.h 00003 // Description: 00004 // Created: 02/15/2007 08:47:46 PM EST 00005 // Revision: none 00006 // Compiler: gcc 3.4.6 00007 // 00008 // Author: John P. Feltz 00009 // Email: jfeltz@gmail.com 00010 // License: Copyright (c) 2006-2007, John P. Feltz 00011 // This program is free software; you can redistribute it and/or 00012 // modify it under the terms of the GNU General Public License as 00013 // published by the Free Software Foundation, version 2 of the 00014 // License. 00015 // This program is distributed in the hope that it will be 00016 // useful, but WITHOUT ANY WARRANTY; without even the implied 00017 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00018 // PURPOSE. 00019 // See the GNU General Public License version 2 for more details. 00020 // 00021 // ===================================================================================== 00022 00023 00024 namespace cmil { 00026 class InputArbitrator : public Logger { 00027 public: 00028 00029 00030 InputData* const getData(const Ev& event) const; 00031 00032 ~InputArbitrator() { 00033 log_debug("dtor"); 00034 m_registry->cleanup() ; delete m_registry; 00035 }; 00036 00037 std::string getDefaultDevice() const; 00038 00039 std::string getName() const { 00040 return "InputArbitrator"; 00041 }; 00042 00043 void quit(); 00044 protected: 00045 friend class InputTranslator; 00046 friend class System; 00047 00048 void registerDevice(InputDevice& dev); 00049 void registerDevices(DeviceRegistry& dev); 00050 00051 const bool isActionCompatible(int id, InputAction* action) const; 00052 00053 const int getID(const Ev& event) const; 00054 InputData* const getData(int id) const; 00055 int getSize() const; 00056 00057 00058 void update(const InputData& input); 00059 void update(const ModData& input); 00060 00061 void attach(InputActor* const actor); 00062 00063 private: 00064 InputArbitrator(DeviceRegistry *reg) : m_registry(reg), m_pActor(NULL) {}; 00065 InputArbitrator() : m_registry(new DeviceRegistry()), m_pActor(NULL) {}; 00066 00067 DeviceRegistry* m_registry; 00068 InputActor* m_pActor; 00069 00070 //restrict copying 00071 InputArbitrator(const InputArbitrator& ); 00072 InputArbitrator& operator=(const InputArbitrator& ); 00073 }; 00074 }