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

# Tools/Module/ModuleSelector.h

Go to the documentation of this file.

    00001 /**
    00002 * @file ModuleSelector.h
    00003 *
    00004 * Definition of class ModuleSelector.
    00005 *
    00006 * @author Max Risler
    00007 * @author Martin Lötzsch
    00008 */
    00009
    00010 #ifndef __ModuleSelector_h_
    00011 #define __ModuleSelector_h_
    00012
    00013 #include "SolutionRequest.h"
    00014 #include "Module.h"
    00015
    00016 /**
    00017 * @class ModuleSelector
    00018 *
    00019 * Base class for module selectors. Module selectors allow to switch between different
    00020 * solutions for a modules.
    00021 *
    00022 * @author Max Risler
    00023 * @author Martin Lötzsch
    00024 */
    00025 class ModuleSelector : public MessageHandler
    00026 {
    00027 protected:
    00028   /** The id of the selected solution */
    00029   SolutionRequest::ModuleSolutionID selectedSolutionID;
    00030
    00031 public:
    00032   /**
    00033   * Constructor
    00034   * @param id The id of the module.
    00035   */
    00036   ModuleSelector(SolutionRequest::ModuleID id);
    00037
    00038   /** Destructor */
    00039   ~ModuleSelector();
    00040
    00041   /**
    00042   * Is called on start and when the selected solution changes
    00043   * to create a specific solution.
    00044   * @param id The id of the solution to create
    00045   * @return The created solution or 0
    00046   */
    00047   virtual Module* createSolution(SolutionRequest::ModuleSolutionID id) = 0;
    00048
    00049   /**
    00050   * Creates the default solution.
    00051   * This can not be done in the constructor,
    00052   * as the derived selector class is not created yet.
    00053   */
    00054   void init();
    00055
    00056   /**
    00057   * Selects a module.
    00058   * @param id id of module to select
    00059   */
    00060   virtual void selectSolution(SolutionRequest::ModuleSolutionID id);
    00061
    00062   /** Returns the index of the selected solution. */
    00063   SolutionRequest::ModuleSolutionID getSelectedSolution() const;
    00064
    00065   /** Executes the selected module */
    00066   virtual void execute();
    00067
    00068   /**
    00069   * Called from a MessageQueue to distribute messages.
    00070   * Use message.getMessageID to decide if the message is relavant for
    00071   * the MesssageHandler derivate.
    00072   * @param message The message that can be read.
    00073   * @return true if the message was read (handled).
    00074   */
    00075   virtual bool handleMessage(InMessage& message);
    00076
    00077   /** RunTime */
    00078   unsigned int frameCounter;
    00079   /** RunTime */
    00080   double averageRunTime;
    00081   /** RunTime */
    00082   unsigned long maxRunTime;
    00083   /** RunTime */
    00084   unsigned long minRunTime;
    00085
    00086
    00087 protected:
    00088
    00089   /** The id of the module, needed only for error messages. */
    00090   SolutionRequest::ModuleID moduleID;
    00091
    00092   /** The selected solution */
    00093   Module *selectedSolution;
    00094 };
    00095
    00096
    00097 #endif /// __ModuleSelector_h_