Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Tools/Module/ModuleHandler.cpp

Go to the documentation of this file.
00001 /**
00002 * @file ModuleHandler.cpp
00003 *
00004 * Implementation of class ModuleHandler.
00005 *
00006 * @author Max Risler
00007 * @author Martin Lötzsch
00008 */
00009 
00010 #include "ModuleHandler.h"
00011 #include "Tools/Debugging/Debugging.h"
00012 
00013 ModuleHandler::ModuleHandler()
00014 {
00015   for(int i = 0; i < SolutionRequest::numOfModules; i++)
00016     pModuleSelectors[i] = 0;
00017 }
00018 
00019 ModuleSelector* ModuleHandler::pGetModuleSelector(SolutionRequest::ModuleID id) const
00020 {
00021   return pModuleSelectors[id];
00022 }
00023 
00024 bool ModuleHandler::handleMessage(InMessage& message)
00025 {
00026   bool handled = false;
00027   for(int i = 0; i < SolutionRequest::numOfModules; i++)
00028   {
00029     if (pModuleSelectors[i] != 0)
00030     {
00031       if (pModuleSelectors[i]->handleMessage(message))
00032       {
00033         handled = true;
00034         message.resetReadPosition();
00035       }
00036     }
00037   }
00038   return handled;
00039 }
00040 
00041 void ModuleHandler::setModuleSelector(SolutionRequest::ModuleID id, ModuleSelector *module)
00042 {
00043   pModuleSelectors[id] = module;
00044   if (module!=0) module->init();
00045 }
00046 
00047 SolutionRequest::ModuleSolutionID ModuleHandler::getSelectedSolution(SolutionRequest::ModuleID id) const
00048 {
00049   if (pModuleSelectors[id] != 0)
00050     return pModuleSelectors[id]->getSelectedSolution();
00051   else
00052     return SolutionRequest::disabled;
00053 }
00054 
00055 void ModuleHandler::selectSolution(SolutionRequest::ModuleID id, SolutionRequest::ModuleSolutionID solution)
00056 {
00057   if (pModuleSelectors[id] != 0 && pModuleSelectors[id]->getSelectedSolution()!=solution)
00058   {
00059     OUTPUT(idText, text, "ModuleHandler::selectSolution :" << 
00060       " Switched solution for " << SolutionRequest::getModuleName(id) <<
00061       " from " << SolutionRequest::getModuleSolutionName(id,pModuleSelectors[id]->getSelectedSolution()) <<
00062       " to " << SolutionRequest::getModuleSolutionName(id,solution) );
00063     pModuleSelectors[id]->selectSolution(solution);
00064   }
00065 }
00066 
00067 void ModuleHandler::selectSolutions(SolutionRequest request)
00068 {
00069   for (int i=0; i < SolutionRequest::numOfModules; i++) 
00070     selectSolution((SolutionRequest::ModuleID)i,request.solutions[i]);
00071 }
00072 
00073 /*
00074  * Change log :
00075  * 
00076  * $Log: ModuleHandler.cpp,v $
00077  * Revision 1.1.1.1  2004/05/22 17:37:19  cvsadm
00078  * created new repository GT2004_WM
00079  *
00080  * Revision 1.2  2004/01/21 14:31:58  loetzsch
00081  * Module Selectors create only the selected solution.
00082  * When the solution changes, the old solution is erased and the new
00083  * one ist created using createSolution(..)
00084  *
00085  * Revision 1.1  2003/10/07 10:13:24  cvsadm
00086  * Created GT2004 (M.J.)
00087  *
00088  * Revision 1.1.1.1  2003/07/02 09:40:29  cvsadm
00089  * created new repository for the competitions in Padova from the 
00090  * tamara CVS (Tuesday 2:00 pm)
00091  *
00092  * removed unused solutions
00093  *
00094  * Revision 1.5  2002/11/19 15:43:04  dueffert
00095  * doxygen comments corrected
00096  *
00097  * Revision 1.4  2002/11/12 18:52:08  risler
00098  * reset read position of handled messaged (fixing crash when e.g. sending walking engine parameters)
00099  *
00100  * Revision 1.3  2002/09/25 10:25:13  loetzsch
00101  * removed the "executeVisionModules" variable
00102  * from SolutionRequest and ModuleHandler.
00103  *
00104  * Revision 1.2  2002/09/10 17:53:26  loetzsch
00105  * First draft of new Module/Solution Architecture
00106  *
00107  * Revision 1.1  2002/09/10 15:53:59  cvsadm
00108  * Created new project GT2003 (M.L.)
00109  * - Cleaned up the /Src/DataTypes directory
00110  * - Removed challenge related source code
00111  * - Removed processing of incoming audio data
00112  * - Renamed AcousticMessage to SoundRequest
00113  *
00114  * Revision 1.3  2002/07/23 13:48:40  loetzsch
00115  * - new streaming classes
00116  * - removed many #include statements
00117  * - exchanged StaticQueue by MessageQueue
00118  * - new debug message handling
00119  * - general clean up
00120  *
00121  * Revision 1.2  2002/06/04 00:12:45  loetzsch
00122  * added bool executeVisionModules
00123  *
00124  * Revision 1.1.1.1  2002/05/10 12:40:32  cvsadm
00125  * Moved GT2002 Project from ute to tamara.
00126  *
00127  * Revision 1.7  2002/02/08 18:36:03  risler
00128  * removed destructor again
00129  *
00130  * Revision 1.6  2002/02/08 17:48:21  risler
00131  * destructor added
00132  *
00133  * Revision 1.5  2002/01/20 13:00:18  risler
00134  * changed implementation of selecting default solution
00135  *
00136  * Revision 1.4  2002/01/19 12:43:16  risler
00137  * enabled SolutionRequest, changed HandleDebugMessage calls
00138  *
00139  * Revision 1.3  2002/01/17 14:35:48  risler
00140  * SolutionRequest added
00141  *
00142  * Revision 1.2  2001/12/10 17:47:10  risler
00143  * change log added
00144  *
00145  */

Generated on Thu Sep 23 19:57:40 2004 for GT2004 by doxygen 1.3.6