Gnash  0.8.11dev
ASHandlers.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 GNASH_ASHANDLERS_H
20 #define GNASH_ASHANDLERS_H
21 
22 #include <vector>
23 
24 #include "SWF.h"
25 
26 // Forward declarations
27 namespace gnash {
28  class ActionExec;
29 }
30 
31 namespace gnash {
32 
33 namespace SWF { // gnash::SWF
34 
36  ARG_NONE = 0,
38  // default hex dump, in case the format is unknown or unsupported
46 };
47 
48 
50 {
51  typedef void (*ActionCallback)(ActionExec& thread);
52 
53 public:
54 
55  ActionHandler();
56  ActionHandler(ActionType type, ActionCallback func,
57  ArgumentType format = ARG_NONE);
58 
60  void execute(ActionExec& thread) const;
61 
62  ActionType getType() const { return _type; }
63  ArgumentType getArgFormat() const { return _arg_format; }
64 
65 private:
66 
67  ActionType _type;
68  ActionCallback _callback;
69  ArgumentType _arg_format;
70 };
71 
74 {
75 public:
76 
78  static const SWFHandlers& instance();
79 
81  void execute(ActionType type, ActionExec& thread) const;
82 
83  size_t size() const { return _handlers.size(); }
84 
85  ActionType lastType() const {
86  return ACTION_GOTOEXPRESSION;
87  }
88 
90  return _handlers[x];
91  }
92 
93 private:
94 
95  // Use the ::instance() method to get a reference
96  SWFHandlers();
97 
98  // You won't destroy a singleton
99  ~SWFHandlers();
100 
101  // Indexed by action id
102  typedef std::vector<ActionHandler> container_type;
103 
104  container_type _handlers;
105 
106 };
107 
108 
109 } // namespace SWF
110 } // namespace gnash
111 
112 #endif
Definition: ASHandlers.h:44
Definition: ASHandlers.h:39
Definition: ASHandlers.h:41
A singleton containing the supported SWF Action handlers.
Definition: ASHandlers.h:73
Definition: ASHandlers.h:42
size_t size() const
Definition: ASHandlers.h:83
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
Definition: ASHandlers.h:40
type
Definition: GnashKey.h:329
ArgumentType
Definition: ASHandlers.h:35
ActionType
SWF action ids. Symbolic names copied from Ming.
Definition: SWF.h:124
void execute(ActionExec &thread) const
Execute the action.
Definition: ASHandlers.cpp:236
aka GOTOFRAME2
Definition: SWF.h:213
Definition: ASHandlers.h:36
Executor of an action_buffer.
Definition: ActionExec.h:118
std::int32_t x
Definition: BitmapData_as.cpp:434
Definition: ASHandlers.h:49
ActionHandler()
Definition: ASHandlers.cpp:218
const ActionHandler & operator[](ActionType x) const
Definition: ASHandlers.h:89
Definition: ASHandlers.h:37
ArgumentType getArgFormat() const
Definition: ASHandlers.h:63
ActionType lastType() const
Definition: ASHandlers.h:85
Definition: ASHandlers.h:45
Definition: ASHandlers.h:43
Definition: GnashKey.h:331
ActionType getType() const
Definition: ASHandlers.h:62