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 
187  as_object* _object;
188 
190  //
192  const fn_call::Args _args;
193 
195  bool _runOnce;
196 };
197 
198 } // namespace gnash
199 
200 #endif
movie_root.h
_object
as_object * _object
Definition: Array_as.cpp:680
gnash::as_object
The base class for all ActionScript objects.
Definition: as_object.h:162
dsodefs.h
gnash::Timer
An interval timer.
Definition: Timers.h:50
gnash::as_environment
Provides information about timeline context.
Definition: as_environment.h:51
gnash::Timer::cleared
bool cleared() const
Return true if interval has been cleared.
Definition: Timers.h:125
gnash::VM
The AVM1 virtual machine.
Definition: VM.h:72
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::Timer::clearInterval
void clearInterval()
Clear the timer, ready for reuse.
Definition: Timers.cpp:69
start
@ start
Definition: klash_part.cpp:330
Global_as.h
gnash::Timer::Timer
Timer(as_function &method, unsigned long ms, as_object *this_ptr, fn_call::Args args, bool runOnce=false)
Construct a Timer, enabling it.
Definition: Timers.cpp:40
gnash::getVM
VM & getVM(const as_environment &env)
Definition: as_environment.h:222
as_function.h
gnash::getMember
as_value getMember(as_object &o, const ObjectURI &uri)
Get a member of an object using AS lookup rules.
Definition: as_object.h:756
gnash::Timer::expired
bool expired(unsigned long now, unsigned long &elapsed)
Get expiration state.
Definition: Timers.cpp:83
gnash::fn_call::Args
FunctionArgs< as_value > Args
Definition: fn_call.h:121
gnash::invoke
DSOEXPORT as_value invoke(const as_value &method, const as_environment &env, as_object *this_ptr, fn_call::Args &args, as_object *super=nullptr, const movie_definition *callerDef=nullptr)
Call an as_value on an as_object.
Definition: Global_as.h:166
gnash::FunctionArgs
A class to contain transferable arguments for a fn_call.
Definition: fn_call.h:57
gnash::Timer::executeAndReset
void executeAndReset()
Execute associated function and reset state.
Definition: Timers.cpp:93
Timers.h
gnash::as_value
ActionScript value type.
Definition: as_value.h:95
VM.h
log.h
gnash::FunctionArgs::setReachable
void setReachable() const
Mark any reachable resources.
Definition: fn_call.h:96
fn_call.h
gnash::VM::getTime
unsigned long int getTime() const
Get the number of milliseconds since VM was started.
Definition: VM.cpp:155
DSOEXPORT
#define DSOEXPORT
Definition: dsodefs.h:55
gnash::Timer::~Timer
~Timer()
Definition: Timers.cpp:36
gnash::ObjectURI
A URI for describing as_objects.
Definition: ObjectURI.h:45
gnash::as_object::get_super
virtual as_object * get_super(const ObjectURI &fname)
Definition: as_object.cpp:445
gnash::as_function
ActionScript Function, either builtin or SWF-defined.
Definition: as_function.h:63
gnash::Timer::markReachableResources
void markReachableResources() const
Mark all reachable resources (for GC)
Definition: Timers.cpp:124
gnash::GcResource::setReachable
void setReachable() const
Mark this resource as being reachable.
Definition: GC.h:92