1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef LIBRARIES_NACL_IO_PEPPER_INTERFACE_DELEGATE_H_
6 #define LIBRARIES_NACL_IO_PEPPER_INTERFACE_DELEGATE_H_
8 #include "nacl_io/pepper_interface.h"
10 // This class allows you to delegate Interface requests to different
11 // PepperInterface-derived classes.
14 // class FooPepperInterface : public PepperInterface {
16 // CoreInterface* GetCoreInterface() { ... };
20 // class BarPepperInterface : public PepperInterface {
22 // VarInterface* GetVarInterface() { ... };
26 // void SomeFunction() {
27 // FooPepperInterface foo;
28 // BarPepperInterface bar;
29 // PepperInterfaceDelegate delegate(pp_instance);
30 // delegate.SetCoreInterface(foo.GetCoreInterface());
31 // delegate.SetVarInterface(bar.GetVarInterface());
37 class PepperInterfaceDelegate
: public PepperInterface
{
39 explicit PepperInterfaceDelegate(PP_Instance instance
);
40 virtual ~PepperInterfaceDelegate();
41 virtual PP_Instance
GetInstance();
45 // These declarations look like:
47 // CoreInterface* GetCoreInterface();
49 #include "nacl_io/pepper/undef_macros.h"
50 #include "nacl_io/pepper/define_empty_macros.h"
51 #undef BEGIN_INTERFACE
52 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \
53 virtual BaseClass* Get##BaseClass();
54 #include "nacl_io/pepper/all_interfaces.h"
56 // Interface delegate setters.
58 // These declarations look like:
60 // void SetCoreInterface(CoreInterface* delegate);
62 #include "nacl_io/pepper/undef_macros.h"
63 #include "nacl_io/pepper/define_empty_macros.h"
64 #undef BEGIN_INTERFACE
65 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \
66 void Set##BaseClass##Delegate(BaseClass* delegate);
67 #include "nacl_io/pepper/all_interfaces.h"
70 PP_Instance instance_
;
71 // Interface delegate pointers.
72 #include "nacl_io/pepper/undef_macros.h"
73 #include "nacl_io/pepper/define_empty_macros.h"
74 #undef BEGIN_INTERFACE
75 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \
76 BaseClass* BaseClass##delegate_;
77 #include "nacl_io/pepper/all_interfaces.h"
80 } // namespace nacl_io
82 #endif // LIBRARIES_NACL_IO_PEPPER_INTERFACE_DELEGATE_H_