Gnash  0.8.10
HostInterface.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00003 //   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 <iosfwd>
00058 
00059 #include "dsodefs.h"
00060 
00061 namespace gnash {
00062 
00064 //
00066 class CustomMessage
00067 {
00068 public:
00069     explicit CustomMessage(const std::string& s,
00070             const boost::any& arg = boost::blank())
00071         :
00072         _name(s),
00073         _arg(arg)
00074     {}
00075     const std::string& name() const { return _name; }
00076     const boost::any& arg() const { return _arg; }
00077 private:
00078     std::string _name;
00079     boost::any _arg;
00080 };
00081 
00083 //
00085 class HostMessage
00086 {
00087 public:
00088 
00090     //
00092     enum KnownEvent {
00093 
00098         SHOW_MOUSE,
00099 
00104         RESIZE_STAGE,
00105 
00110         UPDATE_STAGE,
00111 
00117         SHOW_MENU,
00118 
00124         SET_DISPLAYSTATE,
00125 
00130         SET_CLIPBOARD,
00131 
00136         SCREEN_RESOLUTION,
00137 
00142         SCREEN_DPI,
00143 
00148         PIXEL_ASPECT_RATIO,
00149 
00154         PLAYER_TYPE,
00155 
00160         SCREEN_COLOR,
00161 
00166         NOTIFY_ERROR,
00167 
00172         QUERY,
00173 
00175         EXTERNALINTERFACE_ISPLAYING,
00176         EXTERNALINTERFACE_PAN,
00177         EXTERNALINTERFACE_PLAY,
00178         EXTERNALINTERFACE_REWIND,
00179         EXTERNALINTERFACE_SETZOOMRECT,
00180         EXTERNALINTERFACE_STOPPLAY,
00181         EXTERNALINTERFACE_ZOOM
00182     };
00183 
00184     explicit HostMessage(KnownEvent e, const boost::any& arg = boost::blank())
00185         :
00186         _event(e),
00187         _arg(arg)
00188     {}
00189 
00190     KnownEvent event() const { return _event; }
00191     const boost::any& arg() const { return _arg; }
00192 
00193 private:
00194     KnownEvent _event;
00195     boost::any _arg;
00196 };
00197 
00199 class FsCallback
00200 {
00201 public:
00202     virtual void notify(const std::string& cmd, const std::string& arg) = 0;
00203     virtual ~FsCallback() {}
00204 };
00205 
00207 class HostInterface
00208 {
00209 public:
00210 
00211     virtual ~HostInterface() {}
00212 
00213     typedef boost::variant<HostMessage, CustomMessage> Message;
00214 
00216     //
00219     //
00223     virtual boost::any call(const Message& e) = 0;
00224 
00226     //
00229     virtual void exit() = 0;
00230 
00231 };
00232 
00234 DSOEXPORT std::ostream& operator<<(std::ostream& os, const HostMessage& m);
00235 DSOEXPORT std::ostream& operator<<(std::ostream& os, const CustomMessage& m);
00236 
00238 DSOEXPORT std::ostream& operator<<(std::ostream& os, HostMessage::KnownEvent e);
00239 
00240 
00241 } // namespace gnash
00242 
00243 #endif