Gnash  0.8.11dev
Timers.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef HAVE_TIMERS_H
20 #define HAVE_TIMERS_H
21 
22 #include "dsodefs.h"
23 #include "fn_call.h"
24 
25 #include <limits>
26 
27 // Forward declarations
28 namespace gnash {
29  class as_function;
30  class as_object;
31 }
32 
33 namespace gnash {
34 
36 //
50 {
51 public:
52 
53  ~Timer();
54 
56  //
75  Timer(as_function& method, unsigned long ms, as_object* this_ptr,
76  fn_call::Args args, bool runOnce = false);
77 
79  //
97  Timer(as_object* obj, ObjectURI methodName, unsigned long ms,
98  fn_call::Args args, bool runOnce = false);
99 
101  //
107  void clearInterval();
108 
110  // /// @param now
119  bool expired(unsigned long now, unsigned long& elapsed);
120 
122  //
125  bool cleared() const {
126  return _start == std::numeric_limits<unsigned long>::max();
127  }
128 
130  //
138  void executeAndReset();
139 
141  //
148  void markReachableResources() const;
149 
150 private:
151 
153  void execute();
154 
156  void operator() () { execute(); }
157 
159  unsigned long getInterval() const { return _interval; }
160 
162  unsigned long getStart() const { return _start; }
163 
165  //
168  void start();
169 
171  unsigned int _interval;
172 
174  //
178  unsigned long _start;
179 
182  as_function* _function;
183 
184  ObjectURI _methodName;
185 
188 
190  //
192  const fn_call::Args _args;
193 
195  bool _runOnce;
196 };
197 
198 } // namespace gnash
199 
200 #endif
bool cleared() const
Return true if interval has been cleared.
Definition: Timers.h:125
as_object * _object
Definition: Array_as.cpp:680
Definition: klash_part.cpp:330
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
The base class for all ActionScript objects.
Definition: as_object.h:161
A URI for describing as_objects.
Definition: ObjectURI.h:44
A class to contain transferable arguments for a fn_call.
Definition: as_function.h:30
#define DSOEXPORT
Definition: dsodefs.h:55
An interval timer.
Definition: Timers.h:49
ActionScript Function, either builtin or SWF-defined.
Definition: as_function.h:62