OLD | NEW |
| (Empty) |
1 // Copyright 2010 The Ginsu Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can | |
3 // be found in the LICENSE file. | |
4 | |
5 #ifndef C_SALT_MODULE_H_ | |
6 #define C_SALT_MODULE_H_ | |
7 | |
8 #include "boost/noncopyable.hpp" | |
9 #include "c_salt/scripting_bridge.h" | |
10 | |
11 namespace c_salt { | |
12 | |
13 // The base class for a c_salt-based Native Client module. Pepper makes this | |
14 // a global object, and it exists as long as the module code is loaded. This | |
15 // class is repsonsible for creating Instances (see c_salt/instance.h). | |
16 | |
17 // TODO(dspringer): This becomes a subclass of pp::Module when Pepper v2 | |
18 // becomes available. | |
19 class Instance; | |
20 | |
21 class Module : public boost::noncopyable { | |
22 public: | |
23 // The Module is a singleton. | |
24 static Module& GetModuleSingleton(); | |
25 static void CleanUp(); | |
26 | |
27 // Create and return an instance of the module. The subclass can create a | |
28 // specific class instance. | |
29 virtual Instance* CreateInstance(const NPP& npp_instance) = 0; | |
30 | |
31 // Initialize the OpenGL library for this module. The library termination | |
32 // code is called in the dtor (via CleanUp()). If OpenGL has already been | |
33 // initialized, this is a no-op. | |
34 bool InitializeOpenGL(); | |
35 | |
36 protected: | |
37 Module(); | |
38 virtual ~Module(); | |
39 | |
40 private: | |
41 static Module* module_singleton_; | |
42 bool is_opengl_initialized_; | |
43 }; | |
44 | |
45 // Implemented by the module. Creates the Module associated with this Native | |
46 // Client module. This function is called once when the singleton Module gets | |
47 // created. | |
48 Module* CreateModule(); | |
49 | |
50 } // namespace c_salt | |
51 | |
52 #endif // C_SALT_MODULE_H_ | |
OLD | NEW |