blob: fa2c61923bee205a1a34746104baf615a0435b21 [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// Copyright (c) 2011 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.
4
5#ifndef PPAPI_CPP_MODULE_IMPL_H_
6#define PPAPI_CPP_MODULE_IMPL_H_
7
8/// @file
9/// This file defines some simple function templates that help the C++ wrappers
10/// (and are not for external developers to use).
11
12#include "ppapi/cpp/module.h"
13
14namespace pp {
15
16namespace {
17
18// Specialize this function to return the interface string corresponding to the
19// PP?_XXX structure.
20template <typename T> const char* interface_name() {
21 return NULL;
22}
23
24template <typename T> inline T const* get_interface() {
25 static T const* funcs = reinterpret_cast<T const*>(
26 pp::Module::Get()->GetBrowserInterface(interface_name<T>()));
27 return funcs;
28}
29
30template <typename T> inline bool has_interface() {
31 return get_interface<T>() != NULL;
32}
33
34} // namespace
35
36} // namespace pp
37
38#endif // PPAPI_CPP_MODULE_IMPL_H_
39