/home/jpf/code/cc/project/cmil/src/System.cpp

Go to the documentation of this file.
00001 // =====================================================================================
00002 //       Filename:  System.cpp
00003 //    Description:  
00004 //        Version:  1.0
00005 //        Created:  03/29/2007 06:45:20 PM EDT
00006 //       Revision:  none
00007 //       Compiler:  gcc 3.4.6
00008 // 
00009 //         Author:  John P. Feltz 
00010 //          Email:  jfeltz@gmail.com
00011 //          License:  Copyright (c) 2006-2007, John P. Feltz 
00012 //                    This program is free software; you can redistribute it and/or
00013 //                    modify it under the terms of the GNU General Public License as
00014 //                    published by the Free Software Foundation, version 2 of the
00015 //                    License.
00016 //                    This program is distributed in the hope that it will be
00017 //                    useful, but WITHOUT ANY WARRANTY; without even the implied
00018 //                    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00019 //                    PURPOSE.
00020 //                    See the GNU General Public License version 2 for more details.
00021 // 
00022 // =====================================================================================
00023 
00024 #include <System.h>
00025 
00026 namespace cmil {
00027   class InputTranslator;
00028 
00029   InputTranslator* const TranslatorRegistry::getFirstTranslator() {
00030     log_debug("getFirstTranslator() checking if any translators exist..");
00031 
00032     if(!(m_index.empty()) ) {
00033       log_debug("getFirstTranslator() returning first translator");
00034       return m_index.begin()->second;
00035     }
00036     else {
00037       log_error("getFirstTranslator() no translators exist; returning null.");
00038       return NULL;
00039     }
00040   }
00041 
00042   InputTranslator* const TranslatorRegistry::getTranslator(const std::string& name ) {
00043     return m_index[name];
00044   }
00045 
00046   bool TranslatorRegistry::addTranslator(InputTranslator* translator) {
00047       if(m_index.find(translator->getName()) == m_index.end()) {
00048       
00049         m_index.insert(std::pair<const std::string, InputTranslator* const> 
00050           ( (translator->getName()), translator )); 
00051         
00052         return true;
00053       }
00054 
00055     log_error("addTranslator() not added due to translator with pre-existing name found.");
00056     return false;
00057   }
00058 
00059   void TranslatorRegistry::poll() {
00060     for(Translators::iterator i; i != m_index.end() ; ++i)
00061       (*i).second->poll();
00062   }
00063 
00064   System::System() : m_arbitrator(new InputArbitrator()) {}; 
00065   System::System(InputArbitrator* const arb) : m_arbitrator(arb) {}; 
00066 
00067   void System::attach(InputActor* const actor) {
00068     m_arbitrator->attach(actor);
00069   }
00070 
00071   void System::poll() {
00072     m_translators.poll();
00073   }
00074 
00075   const bool System::isActionCompatible(int id, InputAction* action) const {
00076     return m_arbitrator->isActionCompatible(id, action);
00077   };
00078 
00079   const int System::getID(const Ev& event) const {
00080     return m_arbitrator->getID(event);
00081   };
00082 
00083   InputData* const System::getData(int id) const {
00084     return m_arbitrator->getData(id);
00085   };
00086 
00087   InputData* const System::getData(const Ev& event) const {
00088     return m_arbitrator->getData(event);
00089   }; 
00090 
00091   int System::getSize() const {
00092     return m_arbitrator->getSize();
00093   };
00094 
00095   void System::quit() {
00096     return m_arbitrator->quit();
00097   }
00098 
00099   void System::registerDevices(DeviceRegistry& dev) { 
00100     m_arbitrator->registerDevices(dev);
00101   }  
00102 
00103   void System::update(const InputData& input) {
00104     m_arbitrator->update(input);
00105   }
00106 
00107   void System::update(const ModData& input) {
00108     m_arbitrator->update(input);
00109   }
00110 }

(c) 2006-2007 John P. Feltz
Generated on Wed Jul 25 16:08:02 2007 for Common Media Input Layer by doxygen 1.4.7

SourceForge.net Logo