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 <string>
23 #include <vector>
24 
25 #include "SWF.h"
26 
27 // Forward declarations
28 namespace gnash {
29  class ActionExec;
30 }
31 
32 namespace gnash {
33 
34 namespace SWF { // gnash::SWF
35 
37  ARG_NONE = 0,
39  // default hex dump, in case the format is unknown or unsupported
47 };
48 
49 
51 {
52  typedef void (*ActionCallback)(ActionExec& thread);
53 
54 public:
55 
56  ActionHandler();
57  ActionHandler(ActionType type, ActionCallback func,
58  ArgumentType format = ARG_NONE);
59 
61  void execute(ActionExec& thread) const;
62 
63  ActionType getType() const { return _type; }
64  ArgumentType getArgFormat() const { return _arg_format; }
65 
66 private:
67 
68  ActionType _type;
69  ActionCallback _callback;
70  ArgumentType _arg_format;
71 };
72 
75 {
76 public:
77 
79  static const SWFHandlers& instance();
80 
82  void execute(ActionType type, ActionExec& thread) const;
83 
84  size_t size() const { return _handlers.size(); }
85 
86  ActionType lastType() const {
87  return ACTION_GOTOEXPRESSION;
88  }
89 
91  return _handlers[x];
92  }
93 
94 private:
95 
96  // Use the ::instance() method to get a reference
97  SWFHandlers();
98 
99  // You won't destroy a singleton
100  ~SWFHandlers();
101 
102  // Indexed by action id
103  typedef std::vector<ActionHandler> container_type;
104 
105  container_type _handlers;
106 
107 };
108 
109 
110 } // namespace SWF
111 } // namespace gnash
112 
113 #endif