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(const std::string& s,
70  const boost::any& arg = boost::blank())
71  :
72  _name(s),
73  _arg(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 
182  };
183 
184  explicit HostMessage(KnownEvent e, const boost::any& arg = boost::blank())
185  :
186  _event(e),
187  _arg(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