Pepper_42_C++_interfaces
|
#include <module.h>
Public Types | |
typedef std::map< PP_Instance, Instance * > | InstanceMap |
Public Member Functions | |
Module () | |
virtual | ~Module () |
virtual bool | Init () |
PP_Module | pp_module () const |
PPB_GetInterface | get_browser_interface () const |
Core * | core () |
const void * | GetPluginInterface (const char *interface_name) |
const void * | GetBrowserInterface (const char *interface_name) |
Instance * | InstanceForPPInstance (PP_Instance instance) |
void | AddPluginInterface (const std::string &interface_name, const void *vtable) |
bool | InternalInit (PP_Module mod, PPB_GetInterface get_browser_interface) |
const InstanceMap & | current_instances () const |
Static Public Member Functions | |
static Module * | Get () |
Protected Member Functions | |
virtual Instance * | CreateInstance (PP_Instance instance)=0 |
Friends | |
PP_Bool | Instance_DidCreate (PP_Instance pp_instance, uint32_t argc, const char *argn[], const char *argv[]) |
void | Instance_DidDestroy (PP_Instance instance) |
The Module class. The browser calls CreateInstance() to create an instance of your module on the web page. The browser creates a new instance for each <embed>
tag with type="application/x-nacl"
typedef std::map<PP_Instance, Instance*> pp::Module::InstanceMap |
pp::Module::Module | ( | ) |
|
virtual |
void pp::Module::AddPluginInterface | ( | const std::string & | interface_name, |
const void * | vtable | ||
) |
AddPluginInterface() adds a handler for a provided interface name. When the browser requests that interface name, the provided vtable
will be returned.
In general, modules will not need to call this directly. Instead, the C++ wrappers for each interface will register themselves with this function.
This function may be called more than once with the same interface name and vtable with no effect. However, it may not be used to register a different vtable for an already-registered interface. It will assert for a different registration for an already-registered interface in debug mode, and just ignore the registration in release mode.
[in] | interface_name | The interface name that will receive a handler. |
[in,out] | vtable | The vtable to return for interface_name . |
|
inline |
The core() function returns the core interface for doing basic global operations. The return value is guaranteed to be non-NULL once the module has successfully initialized and during the Init() call.
It will be NULL before Init() has been called.
Definition at line 74 of file module.h.
Referenced by pp::CompletionCallback::MayForce().
|
protectedpure virtual |
CreateInstance() should be overridden to create your own module type.
[in] | instance | A PP_Instance . |
|
inline |
The current_instances() function allows iteration over the current instances in the module.
InstanceMap
of all instances in the module.
|
static |
Get() returns the global instance of this module object, or NULL if the module is not initialized yet.
Referenced by pp::CompletionCallback::MayForce().
|
inline |
The get_browser_interface() function returns the internal get_browser_interface
pointer.
PPB_GetInterface
internal pointer. const void* pp::Module::GetBrowserInterface | ( | const char * | interface_name | ) |
GetBrowserInterface() returns interfaces which the browser implements (i.e. PPB interfaces).
[in] | interface_name | The browser interface for the module to get. |
const void* pp::Module::GetPluginInterface | ( | const char * | interface_name | ) |
GetPluginInterface() implements GetInterface
for the browser to get module interfaces. If you need to provide your own implementations of new interfaces, use AddPluginInterface() which this function will use.
[in] | interface_name | The module interface for the browser to get. |
|
virtual |
Init() is automatically called after the object is created. This is where you can put functions that rely on other parts of the API, now that the module has been created.
Instance* pp::Module::InstanceForPPInstance | ( | PP_Instance | instance | ) |
InstanceForPPInstance() returns the object associated with this PP_Instance
, or NULL if one is not found. This should only be called from the main thread! This instance object may be destroyed at any time on the main thread, so using it on other threads may cause a crash.
[in] | instance | This PP_Instance . |
PP_Instance
, or NULL if one is not found. bool pp::Module::InternalInit | ( | PP_Module | mod, |
PPB_GetInterface | get_browser_interface | ||
) |
function that can be overridden by the base classes.
[in] | mod | A PP_Module . |
[in] | get_browser_interface | The browser interface to set. |
|
inline |
The pp_module() function returns the internal module handle.
PP_Module
internal module handle.
|
friend |
|
friend |