SimEvents.H

Go to the documentation of this file.
00001 /*!@file Simulation/SimEvents.H Instantiations of SimEvent */
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/SimEvents.H $
00035 // $Id: SimEvents.H 10709 2009-02-01 02:11:15Z itti $
00036 //
00037 
00038 #ifndef SIMULATION_SIMEVENTS_H_DEFINED
00039 #define SIMULATION_SIMEVENTS_H_DEFINED
00040 
00041 #include "Simulation/SimEvent.H"
00042 #include "Util/SimTime.H"
00043 
00044 // Only declare very generic SimEvent derivatives here (basically,
00045 // which may be used by many modules and depend only on very low-level
00046 // things). For more specialized SimEvent derivatives, declare them in
00047 // corresponding files in the appropriate directories. For example,
00048 // Neuro/NeuroSimEvents.H
00049 
00050 // ######################################################################
00051 //! Request to break the simulation
00052 /*! Post this and the next SimEventQueue::evolve() we will return with
00053   a break status, usually resulting in terminating the simulation. */
00054 class SimEventBreak : public SimEvent {
00055 public:
00056   //! Constructor
00057   SimEventBreak(SimModule* src, const std::string& reason = "");
00058 
00059   //! Destructor
00060   virtual ~SimEventBreak();
00061 
00062   //! Explain why we break
00063   virtual std::string toString() const;
00064 
00065 private:
00066   std::string itsReason;
00067 };
00068 
00069 // ######################################################################
00070 //! Wait until user presses RETURN key
00071 /*! A SimModule may post this to request that the simulation be paused
00072   until the user presses the RETURN key. For example, this may be used
00073   after a bunch of images have been displayed, to give the user the
00074   time to examine them before continuing with the simulation. This
00075   event is handled directly at the very beginning of
00076   SimEventQueue::evolve(), just before we increment the clock. The
00077   event is displayed, plus a message to invite the user to press
00078   RETURN to continue. */
00079 class SimEventUserWait : public SimEvent {
00080 public:
00081   //! Constuctor
00082   SimEventUserWait(SimModule* src, const std::string& reason = "");
00083 
00084   //! Destructor
00085   virtual ~SimEventUserWait();
00086 
00087   //! Explain why we pause
00088   virtual std::string toString() const;
00089 
00090 private:
00091   std::string itsReason;
00092 };
00093 
00094 // ######################################################################
00095 //! Requests that memory stats be shown now
00096 /*! A SimModule may post this to request that statistics about memory
00097   usage be displayed now. This requires that the user specified
00098   --mem-stats on the command-line, otherwise this event will be
00099   ignored. A frame number is optional, as well as an allocation unit
00100   to show the stats in. */
00101 class SimEventShowMemStats : public SimEvent {
00102 public:
00103   //! Constuctor
00104   SimEventShowMemStats(SimModule* src,
00105                        const int fram = -1, const size_t uni = 0);
00106 
00107   //! Destructor
00108   virtual ~SimEventShowMemStats();
00109 
00110   //! Get frame
00111   int frame() const;
00112 
00113   //! Get allocation unit
00114   size_t unit() const;
00115 
00116 private:
00117   int itsFrame;
00118   int itsUnit;
00119 };
00120 
00121 // ######################################################################
00122 //! Save your outputs
00123 /*! SimOutputFrameSeries (or others) may post this when it is time to
00124   save the next round of outputs. SimModule objects may want to catch
00125   this if they have possible outputs to save. They should then use the
00126   ModelComponentSaveInfo data contained here in the event to decide
00127   how and where to save their stuff. */
00128 class SimEventSaveOutput : public SimEvent {
00129 public:
00130   //! Constuctor
00131   SimEventSaveOutput(SimModule* src,
00132                      const rutz::shared_ptr<ModelComponentSaveInfo>& sinfo);
00133 
00134   //! Destructor
00135   virtual ~SimEventSaveOutput();
00136 
00137   //! Get the saveinfo data
00138   const ModelComponentSaveInfo& sinfo() const;
00139 
00140 private:
00141   const rutz::shared_ptr<ModelComponentSaveInfo> itsSinfo;
00142 };
00143 
00144 // ######################################################################
00145 //! Posted by SimEventQueue at the beginning of each clock tick
00146 /*! A SimModule that registers a callback for this event type will
00147     have its callback triggered at every clock tick. */
00148 class SimEventClockTick : public SimEvent {
00149 public:
00150   //! Constuctor
00151   SimEventClockTick(SimModule* src, const SimTime& t);
00152 
00153   //! Destructor
00154   virtual ~SimEventClockTick();
00155 
00156   //! Time at which the event was created
00157   const SimTime& time() const;
00158 
00159   //! Show the time
00160   virtual std::string toString() const;
00161 
00162 private:
00163   const SimTime itsTime;
00164 };
00165 
00166 // ######################################################################
00167 /* So things look consistent in everyone's emacs... */
00168 /* Local Variables: */
00169 /* mode: c++ */
00170 /* indent-tabs-mode: nil */
00171 /* End: */
00172 
00173 #endif // SIMULATION_SIMEVENTS_H_DEFINED
Generated on Sun May 8 08:42:18 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3