Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InexorContextProvider.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <list> // for list
4 #include <string> // for string
5 
6 #include "include/cef_app.h"
7 #include "include/cef_base.h" // for CefRefPtr, CefString
8 #include "include/cef_v8.h" // for CefV8Value, CefV8Accessor, CefV8Handler
9 #include "include/wrapper/cef_helpers.h"
10 #include "inexor/io/Logging.hpp"
11 
12 namespace inexor {
13 namespace ui {
14 namespace context {
15 
16 class InexorContextProvider : public CefV8Handler,
17  public CefV8Accessor
18 {
19  public:
20  // Initializes the context (or subcontext of a context) as a V8 object
21  virtual void InitializeContext() = 0;
22 
23  // The name of the object
24  virtual std::string GetContextName() = 0;
25 
26  // Returns the common context as a V8 object
27  CefRefPtr<CefV8Value> GetContext();
28 
29  // Hierarchical sub contexts are automatically initialized
30  void InitializeSubContexts();
31  void AddSubContext(InexorContextProvider* sub_context);
32 
33  protected:
34  std::list<InexorContextProvider*> sub_contexts;
35 
36  CefRefPtr<CefV8Value> context;
37 
38  // Helper Methods for reducing verbose code
39  void CreateFunction(const CefString& name);
40  void CreateFunction(const CefString& name, CefRefPtr<CefV8Handler> handler);
41  void CreateVariable(const CefString& name, bool readonly = false);
42  void CreateSubContext(CefRefPtr<InexorContextProvider> sub_context);
43 
44 };
45 
46 }
47 }
48 }
void AddSubContext(InexorContextProvider *sub_context)
Definition: InexorContextProvider.cpp:31
CefRefPtr< CefV8Value > GetContext()
Definition: InexorContextProvider.cpp:11
Definition: InexorContextProvider.hpp:16
Logging stuff including the ingame console logging functionality.
void CreateFunction(const CefString &name)
Definition: InexorContextProvider.cpp:36
void CreateVariable(const CefString &name, bool readonly=false)
Definition: InexorContextProvider.cpp:46
std::list< InexorContextProvider * > sub_contexts
Definition: InexorContextProvider.hpp:34
CefRefPtr< CefV8Value > context
Definition: InexorContextProvider.hpp:36
char string[MAXSTRLEN]
cube-strings (char arrays of fixed size).
Definition: cube_types.hpp:18
void InitializeSubContexts()
Definition: InexorContextProvider.cpp:23
void CreateSubContext(CefRefPtr< InexorContextProvider > sub_context)
Definition: InexorContextProvider.cpp:54