SimEventQueueConfigurator.C

Go to the documentation of this file.
00001 /*!@file Simulation/SimEventQueueConfigurator.C Pick a SimEventQueue */
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: Laurent Itti <itti@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Simulation/SimEventQueueConfigurator.C $
00035 // $Id: SimEventQueueConfigurator.C 8160 2007-03-21 21:34:16Z rjpeters $
00036 //
00037 
00038 #include "Simulation/SimEventQueueConfigurator.H"
00039 #include "Simulation/SimEventQueue.H"
00040 #include "Simulation/SimEventQueueDebug.H"
00041 #include "Component/ModelOptionDef.H"
00042 #include "Simulation/SimulationOpts.H"
00043 
00044 const ModelOptionDef OPT_SimEventQueueType =
00045   { MODOPT_ARG_STRING, "SimEventQueueType", &MOC_SIM, OPTEXP_CORE,
00046     "Type of event queue used to control simulations. Usually you would want "
00047     "to use 'Std', for standard clocking and dispatching of events that "
00048     "arise in various modules being simulated. 'Debug' provides more verbose "
00049     "tracing of events, which is useful to debug simulation flow issues.",
00050     "seq-type", '\0',
00051     "<Std|Debug>", "Std" };
00052 
00053 // ######################################################################
00054 SimEventQueueConfigurator::
00055 SimEventQueueConfigurator(OptionManager& mgr,
00056                           const std::string& descrName,
00057                           const std::string& tagName) :
00058   ModelComponent(mgr, descrName, tagName),
00059   itsSEQname(&OPT_SimEventQueueType, this),
00060   itsQ(new SimEventQueue(mgr))
00061 {
00062   addSubComponent(itsQ);
00063 }
00064 
00065 // ######################################################################
00066 SimEventQueueConfigurator::~SimEventQueueConfigurator()
00067 {  }
00068 
00069 // ######################################################################
00070 nub::ref<SimEventQueue> SimEventQueueConfigurator::getQ() const
00071 { return itsQ; }
00072 
00073 // ######################################################################
00074 void SimEventQueueConfigurator::
00075 paramChanged(ModelParamBase* const param,
00076              const bool valueChanged,
00077              ParamClient::ChangeStatus* status)
00078 {
00079   ModelComponent::paramChanged(param, valueChanged, status);
00080 
00081   // was that a change of our baby's name?
00082   if (param == &itsSEQname) {
00083     // if we had one, let's unregister it (when we later reset() the
00084     // nub::ref, the current SaccadeController will unexport its
00085     // command-line options):
00086     removeSubComponent(*itsQ);
00087 
00088     // instantiate a controller of the appropriate type:
00089     if (itsSEQname.getVal().compare("Std") == 0)
00090       itsQ.reset(new SimEventQueue(getManager()));
00091     else if (itsSEQname.getVal().compare("Debug") == 0)
00092       itsQ.reset(new SimEventQueueDebug(getManager()));
00093     else
00094       LFATAL("Unknown SimEvent Queue type %s",
00095              itsSEQname.getVal().c_str());
00096 
00097     // add our baby as a subcomponent of us so that it will become
00098     // linked to the manager through us (hopefully we are registered
00099     // with the manager), which in turn will allow it to export its
00100     // command-line options and get configured:
00101     addSubComponent(itsQ);
00102 
00103     // tell the controller to export its options:
00104     itsQ->exportOptions(MC_RECURSE);
00105 
00106     // some info message:
00107     LINFO("Selected SimEventQueue of type %s", itsSEQname.getVal().c_str());
00108   }
00109 }
00110 
00111 
00112 // ######################################################################
00113 /* So things look consistent in everyone's emacs... */
00114 /* Local Variables: */
00115 /* mode: c++ */
00116 /* indent-tabs-mode: nil */
00117 /* End: */
Generated on Sun May 8 08:42:18 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3