• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

Timers.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
00003 //   Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 #ifndef HAVE_TIMERS_H
00020 #define HAVE_TIMERS_H
00021 
00022 #include "dsodefs.h"
00023 #include "smart_ptr.h"
00024 #include "fn_call.h"
00025 
00026 #include <string>
00027 #include <limits>
00028 
00029 // Forward declarations
00030 namespace gnash {
00031     class as_function;
00032     class as_object;
00033 }
00034 
00035 namespace gnash {
00036   
00038 //
00052 class DSOEXPORT Timer
00053 {
00054 public:
00055       
00056     ~Timer();
00057 
00059     //
00078     Timer(as_function& method, unsigned long ms, as_object* this_ptr,
00079             const fn_call::Args& args, bool runOnce = false);
00080 
00082     //
00100     Timer(as_object* obj, string_table::key methodName, unsigned long ms,
00101             const fn_call::Args& args, bool runOnce = false);
00102 
00104     //
00110     void clearInterval();
00111 
00113     // /// @param now
00122     bool expired(unsigned long now, unsigned long& elapsed); 
00123 
00125     //
00128     bool cleared() const {
00129           return _start == std::numeric_limits<unsigned long>::max();
00130     }
00131 
00133     //
00141     void executeAndReset();
00142 
00143 #ifdef GNASH_USE_GC
00144 
00145     //
00152     void markReachableResources() const;
00153 #endif // GNASH_USE_GC
00154 
00155 private:
00156 
00158     void execute();
00159 
00161     void operator() () { execute(); }
00162     
00164     unsigned long getInterval() const { return _interval; }
00165 
00167     unsigned long getStart() const { return _start; }
00168 
00170     //
00173     void start();
00174 
00176     unsigned int _interval;
00177 
00179     //
00183     unsigned long _start;
00184 
00187     as_function* _function;
00188 
00189     string_table::key _methodName;
00190 
00192     as_object* _object;
00193 
00195     //
00197     const fn_call::Args _args;
00198 
00200     bool _runOnce;
00201 };
00202   
00203 } // namespace gnash
00204 
00205 #endif

Generated on Fri Mar 16 2012 15:46:13 for Gnash by  doxygen 1.7.1