Gnash  0.8.11dev
HostInterface.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 
50 
51 #ifndef GNASH_HOST_INTERFACE_H
52 #define GNASH_HOST_INTERFACE_H
53 
54 #include <boost/variant.hpp>
55 #include <boost/any.hpp>
56 #include <string>
57 #include <iosfwd>
58 
59 #include "dsodefs.h"
60 
61 namespace gnash {
62 
64 //
67 {
68 public:
69  explicit CustomMessage(std::string s,
70  boost::any arg = boost::blank())
71  :
72  _name(std::move(s)),
73  _arg(std::move(arg))
74  {}
75  const std::string& name() const { return _name; }
76  const boost::any& arg() const { return _arg; }
77 private:
78  std::string _name;
79  boost::any _arg;
80 };
81 
83 //
86 {
87 public:
88 
90  //
92  enum KnownEvent {
93 
99 
105 
111 
118 
125 
131 
137 
143 
149 
155 
161 
167 
173 
181  EXTERNALINTERFACE_ZOOM
182  };
183 
184  explicit HostMessage(KnownEvent e, boost::any arg = boost::blank())
185  :
186  _event(e),
187  _arg(std::move(arg))
188  {}
189 
190  KnownEvent event() const { return _event; }
191  const boost::any& arg() const { return _arg; }
192 
193 private:
194  KnownEvent _event;
195  boost::any _arg;
196 };
197 
200 {
201 public:
202  virtual void notify(const std::string& cmd, const std::string& arg) = 0;
203  virtual ~FsCallback() {}
204 };
205 
208 {
209 public:
210 
211  virtual ~HostInterface() {}
212 
213  typedef boost::variant<HostMessage, CustomMessage> Message;
214 
216  //
219  //
223  virtual boost::any call(const Message& e) = 0;
224 
226  //
229  virtual void exit() = 0;
230 
231 };
232 
234 DSOEXPORT std::ostream& operator<<(std::ostream& os, const HostMessage& m);
235 DSOEXPORT std::ostream& operator<<(std::ostream& os, const CustomMessage& m);
236 
238 DSOEXPORT std::ostream& operator<<(std::ostream& os, HostMessage::KnownEvent e);
239 
240 
241 } // namespace gnash
242 
243 #endif
Definition: HostInterface.h:176
KnownEvent
The messages that a hosting application should handle.
Definition: HostInterface.h:92
Definition: HostInterface.h:166
HostMessage(KnownEvent e, boost::any arg=boost::blank())
Definition: HostInterface.h:184
Built-in forms of communication with the host application.
Definition: HostInterface.h:85
Abstract base class for FS handlers.
Definition: HostInterface.h:199
Definition: HostInterface.h:160
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
Definition: HostInterface.h:130
boost::variant< HostMessage, CustomMessage > Message
Definition: HostInterface.h:213
A custom form of communication with the host application.
Definition: HostInterface.h:66
CustomMessage(std::string s, boost::any arg=boost::blank())
Definition: HostInterface.h:69
Definition: HostInterface.h:180
Definition: HostInterface.h:124
std::ostream & operator<<(std::ostream &o, const URL &u)
Definition: URL.cpp:447
Definition: HostInterface.h:117
virtual ~FsCallback()
Definition: HostInterface.h:203
Definition: HostInterface.h:154
Definition: HostInterface.h:177
Definition: HostInterface.h:148
const boost::any & arg() const
Definition: HostInterface.h:191
virtual ~HostInterface()
Definition: HostInterface.h:211
#define DSOEXPORT
Definition: dsodefs.h:55
KnownEvent event() const
Definition: HostInterface.h:190
Definition: HostInterface.h:136
Definition: HostInterface.h:110
Definition: HostInterface.h:104
const std::string & name() const
Definition: HostInterface.h:75
Definition: GnashKey.h:151
Definition: HostInterface.h:178
Abstract base class for hosting app handler.
Definition: HostInterface.h:207
Definition: HostInterface.h:98
Definition: GnashKey.h:159
Definition: GnashKey.h:165
Definition: HostInterface.h:172
Definition: HostInterface.h:142
const boost::any & arg() const
Definition: HostInterface.h:76