Gnash 0.8.9

HostInterface.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
00003 //   2011 Free Software Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00050 
00051 #ifndef GNASH_HOST_INTERFACE_H
00052 #define GNASH_HOST_INTERFACE_H
00053 
00054 #include <boost/variant.hpp>
00055 #include <boost/any.hpp>
00056 #include <string>
00057 #include <ostream>
00058 
00059 namespace gnash {
00060 
00062 //
00064 class CustomMessage
00065 {
00066 public:
00067     explicit CustomMessage(const std::string& s,
00068             const boost::any& arg = boost::blank())
00069         :
00070         _name(s),
00071         _arg(arg)
00072     {}
00073     const std::string& name() const { return _name; }
00074     const boost::any& arg() const { return _arg; }
00075 private:
00076     std::string _name;
00077     boost::any _arg;
00078 };
00079 
00081 //
00083 class HostMessage
00084 {
00085 public:
00086 
00088     //
00090     enum KnownEvent {
00091 
00096         SHOW_MOUSE,
00097 
00102         RESIZE_STAGE,
00103 
00108         UPDATE_STAGE,
00109 
00115         SHOW_MENU,
00116 
00122         SET_DISPLAYSTATE,
00123 
00128         SET_CLIPBOARD,
00129 
00134         SCREEN_RESOLUTION,
00135 
00140         SCREEN_DPI,
00141 
00146         PIXEL_ASPECT_RATIO,
00147 
00152         PLAYER_TYPE,
00153 
00158         SCREEN_COLOR,
00159 
00164         NOTIFY_ERROR,
00165 
00170         QUERY,
00171 
00173         EXTERNALINTERFACE_ISPLAYING,
00174         EXTERNALINTERFACE_PAN,
00175         EXTERNALINTERFACE_PLAY,
00176         EXTERNALINTERFACE_REWIND,
00177         EXTERNALINTERFACE_SETZOOMRECT,
00178         EXTERNALINTERFACE_STOPPLAY,
00179         EXTERNALINTERFACE_ZOOM
00180     };
00181 
00182     explicit HostMessage(KnownEvent e, const boost::any& arg = boost::blank())
00183         :
00184         _event(e),
00185         _arg(arg)
00186     {}
00187 
00188     KnownEvent event() const { return _event; }
00189     const boost::any& arg() const { return _arg; }
00190 
00191 private:
00192     KnownEvent _event;
00193     boost::any _arg;
00194 };
00195 
00197 class FsCallback
00198 {
00199 public:
00200     virtual void notify(const std::string& cmd, const std::string& arg) = 0;
00201     virtual ~FsCallback() {}
00202 };
00203 
00205 class HostInterface
00206 {
00207 public:
00208 
00209     virtual ~HostInterface() {}
00210 
00211     typedef boost::variant<HostMessage, CustomMessage> Message;
00212 
00214     //
00217     //
00221     virtual boost::any call(const Message& e) = 0;
00222 
00224     //
00227     virtual void exit() = 0;
00228 
00229 };
00230 
00232 std::ostream& operator<<(std::ostream& os, const HostMessage& m);
00233 std::ostream& operator<<(std::ostream& os, const CustomMessage& m);
00234 
00236 std::ostream& operator<<(std::ostream& os, HostMessage::KnownEvent e);
00237 
00238 
00239 } // namespace gnash
00240 
00241 #endif