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

Tools/Module/ModuleSelector.cpp

Go to the documentation of this file.
00001 /**
00002 * @file ModuleSelector.cpp
00003 * 
00004 * Implementation of class ModuleSelector.
00005 *
00006 * @author Max Risler
00007 * @author Martin Lötzsch
00008 */
00009 
00010 #include "ModuleSelector.h"
00011 #include "Platform/GTAssert.h"
00012 #include "Tools/Debugging/Debugging.h"
00013 
00014 ModuleSelector::ModuleSelector(SolutionRequest::ModuleID id) 
00015 : moduleID(id), selectedSolution(0)
00016 {
00017   selectedSolutionID = SolutionRequest::getDefaultSolution(id);
00018 }
00019 
00020 ModuleSelector::~ModuleSelector()
00021 {
00022   if (selectedSolution != 0) delete selectedSolution;
00023 }
00024 
00025 void ModuleSelector::selectSolution(SolutionRequest::ModuleSolutionID id) 
00026 {
00027   ASSERT(id < solutionRequestMaxNumOfSolutions);
00028   if (id != selectedSolutionID)
00029   {
00030     if (selectedSolution != 0) 
00031     {
00032       delete selectedSolution;
00033     }
00034     selectedSolutionID=id;
00035     init();
00036   }
00037 }
00038 
00039 SolutionRequest::ModuleSolutionID ModuleSelector::getSelectedSolution() const 
00040 {
00041   return selectedSolutionID;
00042 }
00043 
00044 void ModuleSelector::execute() 
00045 {
00046   if (selectedSolution != 0) selectedSolution->execute();
00047 }
00048 
00049 bool ModuleSelector::handleMessage(InMessage& message)
00050 {
00051   if (selectedSolution != 0) 
00052     return selectedSolution->handleMessage(message);
00053   else 
00054     return false;
00055 }
00056 
00057 void ModuleSelector::init()
00058 {
00059   selectedSolution = this->createSolution(selectedSolutionID);
00060   if ((selectedSolution == 0)&&(selectedSolutionID != SolutionRequest::disabled))
00061   {
00062     OUTPUT(idText,text,"ModuleSelector::init(): could not create default solution \""
00063       << SolutionRequest::getModuleSolutionName(moduleID,selectedSolutionID) 
00064       << "\" of module \"" 
00065       << SolutionRequest::getModuleName(moduleID) << "\".");
00066   }
00067 }
00068 
00069 /*
00070 * Change Log:
00071 *
00072 * $Log: ModuleSelector.cpp,v $
00073 * Revision 1.1.1.1  2004/05/22 17:37:19  cvsadm
00074 * created new repository GT2004_WM
00075 *
00076 * Revision 1.3  2004/02/16 16:21:31  dueffert
00077 * ModuleSelectors can actively disable modules now, eg for empty but initialized colorTable
00078 *
00079 * Revision 1.2  2004/01/21 14:31:58  loetzsch
00080 * Module Selectors create only the selected solution.
00081 * When the solution changes, the old solution is erased and the new
00082 * one ist created using createSolution(..)
00083 *
00084 * Revision 1.1  2003/10/07 10:13:24  cvsadm
00085 * Created GT2004 (M.J.)
00086 *
00087 * Revision 1.1.1.1  2003/07/02 09:40:29  cvsadm
00088 * created new repository for the competitions in Padova from the 
00089 * tamara CVS (Tuesday 2:00 pm)
00090 *
00091 * removed unused solutions
00092 *
00093 * Revision 1.3  2002/09/10 21:07:30  loetzsch
00094 * continued change of module/solution mechanisms
00095 *
00096 * Revision 1.2  2002/09/10 17:53:26  loetzsch
00097 * First draft of new Module/Solution Architecture
00098 *
00099 */

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