- add sources.
[platform/framework/web/crosswalk.git] / src / ppapi / cpp / module_impl.h
1 // 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
14 namespace pp {
15
16 namespace {
17
18 // Specialize this function to return the interface string corresponding to the
19 // PP?_XXX structure.
20 template <typename T> const char* interface_name() {
21   return NULL;
22 }
23
24 template <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
30 template <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