Gnash  0.8.11dev
SWFMovie.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 // Stateful live Movie instance
20 
21 
22 #ifndef GNASH_SWF_MOVIE_H
23 #define GNASH_SWF_MOVIE_H
24 
25 #include <boost/intrusive_ptr.hpp>
26 #include <string>
27 #include <map>
28 
29 #include "Movie.h" // for inheritance
30 #include "SWFMovieDefinition.h" // for dtor visibility by smart ptr
31 #include "dsodefs.h" // for DSOTEXPORT
32 
33 // Forward declarations
34 namespace gnash {
35  class DisplayObject;
36 }
37 
38 namespace gnash
39 {
40 
42 //
44 //
50 class SWFMovie : public Movie
51 {
52 
54  typedef std::map<boost::uint16_t, bool> Characters;
55 
56 public:
57 
58  DSOTEXPORT SWFMovie(as_object* object, const SWFMovieDefinition* def,
60 
61  virtual ~SWFMovie() {}
62 
63  virtual void advance();
64 
65  virtual float frameRate() const {
66  return _def->get_frame_rate();
67  }
68 
69  virtual size_t widthPixels() const {
70  return _def->get_width_pixels();
71  }
72 
73  virtual size_t heightPixels() const {
74  return _def->get_height_pixels();
75  }
76 
77  virtual bool ensureFrameLoaded(size_t frameNo) const {
78  return _def->ensure_frame_loaded(frameNo);
79  }
80 
82  //
87  void construct(as_object* init = 0);
88 
90  const std::string& url() const {
91  return _def->get_url();
92  }
93 
95  //
97  int version() const {
98  return _def->get_version();
99  }
100 
102  //
105  //
109  virtual SWF::DefinitionTag* exportedCharacter(const std::string& symbol);
110 
112  //
116  //
120  void addCharacter(boost::uint16_t id);
121 
123  //
126  //
133  bool initializeCharacter(boost::uint16_t id);
134 
135  const movie_definition* definition() const {
136  return _def.get();
137  }
138 
139 private:
140 
142  Characters _characters;
143 
145  const boost::intrusive_ptr<const SWFMovieDefinition> _def;
146 };
147 
148 
149 } // end of namespace gnash
150 
151 #endif // GNASH_MOVIE_INSTANCE_H