Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

timeout.h

Go to the documentation of this file.
00001 #ifndef __TIMEOUT_H_INCLUDED__
00002 #define __TIMEOUT_H_INCLUDED__
00003 
00004 // $Id$
00005 
00006 //**********************************************************************
00007 //                                                                     *
00008 //                                                                     *
00009 //    Description:   Timeout class.  Invokes a callback function on    *
00010 //                   expiration.                                       *
00011 //                                                                     *
00012 //    Author:        Chris White (whitecf@bcs.org.uk)                  *
00013 //                                                                     *
00014 //    Copyright (C) 2003  Monitor Computing Services Ltd.              *
00015 //                                                                     *
00016 //    This program is free software; you can redistribute it and/or    *
00017 //    modify it under the terms of the GNU General Public License      *
00018 //    as published by the Free Software Foundation; either version 2   *
00019 //    of the License, or any later version.                            *
00020 //                                                                     *
00021 //    This program is distributed in the hope that it will be useful,  *
00022 //    but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00023 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00024 //    GNU General Public License for more details.                     *
00025 //                                                                     *
00026 //    You should have received a copy of the GNU General Public        *
00027 //    License (http://www.gnu.org/copyleft/gpl.html) along with this   *
00028 //    program; if not, write to:                                       *
00029 //       The Free Software Foundation Inc.,                            *
00030 //       59 Temple Place - Suite 330,                                  *
00031 //       Boston, MA  02111-1307,                                       *
00032 //       USA.                                                          *
00033 //                                                                     *
00034 //**********************************************************************
00035 //                                                                     *
00036 //    Notes:                                                           *
00037 //                                                                     *
00038 //**********************************************************************
00039 
00040 
00041 #include <cstring.h>
00042 #include <time.h>
00043 
00044 #include <watchble.h>
00045 
00046 
00047 namespace Monitor {
00048 namespace Utility {
00049 
00053 class Timeout : public Watchable
00054 {
00055 public:
00064     Timeout(const CallbackBase&    newWatch,
00065             unsigned               newPeriod,
00066             const string&          newName = "");
00067 
00074     Timeout(unsigned               newPeriod,
00075             const string&          newName = "");
00076 
00081     virtual ~Timeout();
00082 
00083 
00087     int
00088     operator==(const Timeout&    other);
00089 
00090 
00097     void
00098     reset(unsigned    newPeriod = 0);
00099 
00103     int
00104     hasExpired() const;
00105 
00112     int
00113     run();
00114 
00118     const string&
00119     getTimeoutName() const;
00120 
00121 private:
00125     unsigned    period;
00126 
00130     clock_t    endTime;
00131 
00135     Timeout() {;}
00136 
00140     Timeout(const Timeout&) {;}
00141 
00142 
00146     Timeout&
00147     operator=(const Timeout&) {return *this;}
00148 
00152     virtual int
00153     canRun();
00154 
00158     void
00159     expire();
00160 
00161     string    timeoutName;
00162     int       expiredFlag;
00163 };
00164 
00165 };  // namespace Utility
00166 };  // namespace Monitor
00167 
00168 #endif // __TIMEOUT_H_INCLUDED__

Generated on Wed Oct 29 20:51:59 2003 for Utility BC Common by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002