Pepper_56_C++_interfaces
Pepper_56_C++_interfaces
 All Classes Namespaces Files Functions Typedefs Enumerations Macros Groups
pp::Module Class Referenceabstract

#include <module.h>

Public Types

typedef std::map< PP_Instance,
Instance * > 
InstanceMap
 

Public Member Functions

virtual bool Init ()
 
PP_Module pp_module () const
 
PPB_GetInterface get_browser_interface () const
 
Corecore ()
 
const void * GetPluginInterface (const char *interface_name)
 
const void * GetBrowserInterface (const char *interface_name)
 
InstanceInstanceForPPInstance (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 ModuleGet ()
 

Protected Member Functions

virtual InstanceCreateInstance (PP_Instance instance)=0
 

Protected Attributes

InstanceMap current_instances_
 

Friends

PP_Bool Instance_DidCreate (PP_Instance pp_instance, uint32_t argc, const char *argn[], const char *argv[])
 
void Instance_DidDestroy (PP_Instance instance)
 

Detailed Description

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"

Member Function Documentation

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.

Parameters
[in]interface_nameThe interface name that will receive a handler.
[in,out]vtableThe vtable to return for interface_name.
Core* pp::Module::core ( )
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.

Returns
The core interface for doing basic global operations.
virtual Instance* pp::Module::CreateInstance ( PP_Instance  instance)
protectedpure virtual

CreateInstance() should be overridden to create your own module type.

Parameters
[in]instanceA PP_Instance.
Returns
The resulting instance.
const InstanceMap& pp::Module::current_instances ( ) const
inline

The current_instances() function allows iteration over the current instances in the module.

Returns
An InstanceMap of all instances in the module.
static Module* pp::Module::Get ( )
static

Get() returns the global instance of this module object, or NULL if the module is not initialized yet.

Returns
The global instance of the module object.
PPB_GetInterface pp::Module::get_browser_interface ( ) const
inline

The get_browser_interface() function returns the internal get_browser_interface pointer.

Returns
A PPB_GetInterface internal pointer.
const void* pp::Module::GetBrowserInterface ( const char *  interface_name)

GetBrowserInterface() returns interfaces which the browser implements (i.e. PPB interfaces).

Parameters
[in]interface_nameThe 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.

Parameters
[in]interface_nameThe module interface for the browser to get.
virtual bool pp::Module::Init ( )
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.

Returns
true if successful, otherwise false.
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.

Parameters
[in]instanceThis PP_Instance.
Returns
The object associated with this 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.

Parameters
[in]modA PP_Module.
[in]get_browser_interfaceThe browser interface to set.
Returns
true if successful, otherwise false.
PP_Module pp::Module::pp_module ( ) const
inline

The pp_module() function returns the internal module handle.

Returns
A PP_Module internal module handle.

The documentation for this class was generated from the following file: