00001 /** 00002 \file Robots/LoBot/control/LoCountdown.H 00003 \brief A stop watch behaviour that measures the time elapsed and quits 00004 the high-level controller's application when the count hits zero. 00005 */ 00006 00007 // //////////////////////////////////////////////////////////////////// // 00008 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 // 00009 // by the University of Southern California (USC) and the iLab at USC. // 00010 // See http://iLab.usc.edu for information about this project. // 00011 // //////////////////////////////////////////////////////////////////// // 00012 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00013 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00014 // in Visual Environments, and Applications'' by Christof Koch and // 00015 // Laurent Itti, California Institute of Technology, 2001 (patent // 00016 // pending; application number 09/912,225 filed July 23, 2001; see // 00017 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00018 // //////////////////////////////////////////////////////////////////// // 00019 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00020 // // 00021 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00022 // redistribute it and/or modify it under the terms of the GNU General // 00023 // Public License as published by the Free Software Foundation; either // 00024 // version 2 of the License, or (at your option) any later version. // 00025 // // 00026 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00027 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00028 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00029 // PURPOSE. See the GNU General Public License for more details. // 00030 // // 00031 // You should have received a copy of the GNU General Public License // 00032 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00033 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00034 // Boston, MA 02111-1307 USA. // 00035 // //////////////////////////////////////////////////////////////////// // 00036 // 00037 // Primary maintainer for this file: mviswana usc edu 00038 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/LoBot/control/LoCountdown.H $ 00039 // $Id: LoCountdown.H 14305 2010-12-08 21:17:33Z mviswana $ 00040 // 00041 00042 #ifndef LOBOT_COUNTDOWN_BEHAVIOUR_DOT_H 00043 #define LOBOT_COUNTDOWN_BEHAVIOUR_DOT_H 00044 00045 //------------------------------ HEADERS -------------------------------- 00046 00047 // lobot headers 00048 #include "Robots/LoBot/control/LoBehavior.H" 00049 #include "Robots/LoBot/misc/factory.hh" 00050 00051 //----------------------------- NAMESPACE ------------------------------- 00052 00053 namespace lobot { 00054 00055 //------------------------- CLASS DEFINITION ---------------------------- 00056 00057 /** 00058 \class lobot::Countdown 00059 \brief A "stop watch" behaviour that either pauses the robot or quits 00060 the controller application once the counter hits zero. 00061 00062 This class implements a behaviour that keeps track of how much time 00063 has elapsed since the robot started running. When this time exceeds 00064 some preconfigured duration, the behaviour will quit the high-level 00065 controller application. 00066 00067 NOTE: The stop watch continues to count down even if the robot is 00068 paused! 00069 */ 00070 class Countdown : public Behavior { 00071 // Prevent copy and assignment 00072 Countdown(const Countdown&) ; 00073 Countdown& operator=(const Countdown&) ; 00074 00075 // Handy type to have around in a derived class 00076 typedef Behavior base ; 00077 00078 // Boilerplate code to make the generic factory design pattern work 00079 friend class subfactory<Countdown, base> ; 00080 typedef register_factory<Countdown, base> my_factory ; 00081 static my_factory register_me ; 00082 00083 /// This variable keeps track of when the behaviour was started. 00084 long long m_time ; 00085 00086 /// A private constructor because behaviours are instantiated with an 00087 /// object factory and not directly by clients. 00088 Countdown() ; 00089 00090 /// Record the time when the behaviour starts running. 00091 void pre_run() ; 00092 00093 /// This method provides the body of the behaviour's main loop. 00094 void action() ; 00095 00096 /// Clean-up. 00097 ~Countdown() ; 00098 } ; 00099 00100 //----------------------------------------------------------------------- 00101 00102 } // end of namespace encapsulating this file's definitions 00103 00104 #endif 00105 00106 /* So things look consistent in everyone's emacs... */ 00107 /* Local Variables: */ 00108 /* indent-tabs-mode: nil */ 00109 /* End: */