OptionManager.H

Go to the documentation of this file.
00001 /*!@file Component/OptionManager.H */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00005 // by the University of Southern California (USC) and the iLab at USC.  //
00006 // See http://iLab.usc.edu for information about this project.          //
00007 // //////////////////////////////////////////////////////////////////// //
00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00010 // in Visual Environments, and Applications'' by Christof Koch and      //
00011 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00012 // pending; application number 09/912,225 filed July 23, 2001; see      //
00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00014 // //////////////////////////////////////////////////////////////////// //
00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00016 //                                                                      //
00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00018 // redistribute it and/or modify it under the terms of the GNU General  //
00019 // Public License as published by the Free Software Foundation; either  //
00020 // version 2 of the License, or (at your option) any later version.     //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00025 // PURPOSE.  See the GNU General Public License for more details.       //
00026 //                                                                      //
00027 // You should have received a copy of the GNU General Public License    //
00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00030 // Boston, MA 02111-1307 USA.                                           //
00031 // //////////////////////////////////////////////////////////////////// //
00032 //
00033 // Primary maintainer for this file:
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Component/OptionManager.H $
00035 // $Id: OptionManager.H 6466 2006-04-13 19:12:17Z rjpeters $
00036 //
00037 
00038 #ifndef COMPONENT_OPTIONMANAGER_H_DEFINED
00039 #define COMPONENT_OPTIONMANAGER_H_DEFINED
00040 
00041 #include "Util/Types.H" // for uint
00042 
00043 #include <string>
00044 
00045 class ModelOptionDef;
00046 class OptionedModelParam;
00047 class SimTime;
00048 
00049 //! Abstract interface for the option-managing part of ModelManager.
00050 class OptionManager
00051 {
00052 public:
00053   //! Default constructor.
00054   OptionManager();
00055 
00056   //! Virtual destructor for proper base class destruction.
00057   virtual ~OptionManager();
00058 
00059   // ######################################################################
00060   /*! @name Command-line options */
00061   //@{
00062 
00063   //! ModelComponent objects may request a command-line option here
00064   /*! @param p the ModelParam data member of c corresponding to the
00065              option
00066 
00067       @param useMyVal if true, we will do a setOptionValString() using
00068              the current value of the parameter, so that this value
00069              will be propagated to all OptionedModelParam objects that
00070              have requested this option and will become the new
00071              command-line default value. If false, the ModelParam p
00072              will be updated to the current value of the option. So,
00073              use useMyVal=true if your component wishes to push its
00074              current parameter value as the default for everyone using
00075              this option, and use false if your component wishes to
00076              use the current default instead. */
00077   virtual void requestOption(OptionedModelParam& p,
00078                              const bool useMyVal = false) = 0;
00079 
00080   //! Request the removal of a param from the command-line options
00081   /*! @param p the ModelParam data member of c corresponding to the option */
00082   virtual void unRequestOption(OptionedModelParam& p) = 0;
00083 
00084   //! Users may request model option aliases
00085   /*! @param name the name of the option alias, from ModelOptionDefs.C */
00086   virtual void requestOptionAlias(const ModelOptionDef* def) = 0;
00087 
00088   //! Set an option value
00089   /*! All ModelParam objects associated this ModelOptionDef will be
00090       updated with the new value. Will throw a fatal error if the
00091       model has been started (see ModelComponent::start()). */
00092   virtual void setOptionValString(const ModelOptionDef* def,
00093                                   const std::string& val) = 0;
00094 
00095   //! Get an option value
00096   /*! The value returned here is the value currently held by the
00097       ModelManager. This value is updated in three cases: 1) when a
00098       new component requests the option using requestOption() with
00099       useMyVal true; 2) when setOptionValString() is called, and 3)
00100       when the command-line arguments are parsed by ParseCommandLine,
00101       if a value for this option has been specified in the command
00102       line. If ModelComponent objects modify their local ModelParam
00103       values for their local parameter with this name, the value
00104       returned here will not be affected. */
00105   virtual std::string getOptionValString(const ModelOptionDef* def) = 0;
00106 
00107   //! Check if anybody has requested the given option.
00108   virtual bool isOptionRequested(const ModelOptionDef* def) const = 0;
00109 
00110   //@}
00111 
00112   // ######################################################################
00113   /*! @name Alternative access to internal options
00114 
00115       These functions may be useful for alternative methods of
00116       displaying the help for command-line options (e.g. in the Qt
00117       ModelManagerWizard).
00118    */
00119   //@{
00120 
00121   //! Get the number of ModelOptionDef objects in our list.
00122   virtual uint numOptionDefs() const = 0;
00123 
00124   //! Get ModelOptionDef objects from our list, up to the size of the given array.
00125   /*! Returns the number of array entries that were actually filled
00126     with valid ModelOptionDef pointers. */
00127   virtual uint getOptionDefs(const ModelOptionDef** arr, uint narr) = 0;
00128 
00129   //! Get the ModelOptionDef for the given name.
00130   /*! Aborts if there is no such ModelOptionDef. */
00131   virtual const ModelOptionDef* findOptionDef(const char* name) const = 0;
00132 
00133   //! Query if the given ModelOptionDef is used in this program.
00134   virtual bool isOptionDefUsed(const ModelOptionDef* def) const = 0;
00135 
00136   //@}
00137 };
00138 
00139 // ######################################################################
00140 /* So things look consistent in everyone's emacs... */
00141 /* Local Variables: */
00142 /* indent-tabs-mode: nil */
00143 /* End: */
00144 
00145 #endif // COMPONENT_OPTIONMANAGER_H_DEFINED
Generated on Sun May 8 08:40:23 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3