MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
backend.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 #include <cstdlib>
5 #include <memory>
6 
7 namespace mbgl {
8 namespace gfx {
9 
10 class Backend {
11 public:
13  enum class Type : uint8_t {
14  OpenGL,
15  TYPE_MAX,
17  };
18 
19  static constexpr Type DefaultType = Type::OpenGL;
20 
21  static void SetType(const Type value) {
22  if (Value(value) != value) {
23  abort(); // SetType must be called prior to any GetType calls.
24  }
25  }
26 
27  static Type GetType() {
28  return Value(DefaultType);
29  }
30 
31  template <typename T, typename... Args>
32  static std::unique_ptr<T> Create(Args... args) {
33  return Create<Type::OpenGL, T, Args...>(std::forward<Args>(args)...);
34  }
35 
36 private:
37  template <Type, typename T, typename... Args>
38  static std::unique_ptr<T> Create(Args...);
39 
40  static Type Value(Type value) {
41  static const Type type = value;
42  return type;
43  }
44 };
45 
46 } // namespace gfx
47 } // namespace mbgl
static constexpr Type DefaultType
Definition: backend.hpp:19
static std::unique_ptr< T > Create(Args... args)
Definition: backend.hpp:32
static void SetType(const Type value)
Definition: backend.hpp:21
Type
The active graphics API/backend type.
Definition: backend.hpp:13
@ OpenGL
The OpenGL API backend.
static Type GetType()
Definition: backend.hpp:27
Definition: actor.hpp:15
mapbox::base::Value Value
Definition: feature.hpp:11