OGLplus  (0.59.0) a C++ wrapper for rendering APIs

basic_egl_api.hpp
Go to the documentation of this file.
1 #ifndef EGLPLUS_BASIC_EGL_API_HPP
9 #define EGLPLUS_BASIC_EGL_API_HPP
10 
11 #include "egl_api/api.hpp"
12 #include "egl_api/api_traits.hpp"
13 #include "egl_api/constants.hpp"
14 
15 namespace eagine::eglp {
16 //------------------------------------------------------------------------------
17 template <typename ApiTraits>
18 class basic_egl_api
19  : protected ApiTraits
20  , public basic_egl_operations<ApiTraits>
21  , public basic_egl_constants<ApiTraits> {
22 public:
23  basic_egl_api(ApiTraits traits)
24  : ApiTraits{std::move(traits)}
25  , basic_egl_operations<ApiTraits>{*static_cast<ApiTraits*>(this)}
26  , basic_egl_constants<ApiTraits>{
27  *static_cast<ApiTraits*>(this),
28  *static_cast<basic_egl_operations<ApiTraits>*>(this)} {}
29 
30  basic_egl_api()
31  : basic_egl_api{ApiTraits{}} {}
32 
33  auto operations() noexcept -> basic_egl_operations<ApiTraits>& {
34  return *this;
35  }
36 
37  auto operations() const noexcept -> const basic_egl_operations<ApiTraits>& {
38  return *this;
39  }
40 
41  auto constants() noexcept -> basic_egl_constants<ApiTraits>& {
42  return *this;
43  }
44 
45  auto constants() const noexcept -> const basic_egl_constants<ApiTraits>& {
46  return *this;
47  }
48 };
49 
50 template <std::size_t I, typename ApiTraits>
51 auto get(basic_egl_api<ApiTraits>& x) noexcept ->
52  typename std::tuple_element<I, basic_egl_api<ApiTraits>>::type& {
53  return x;
54 }
55 
56 template <std::size_t I, typename ApiTraits>
57 auto get(const basic_egl_api<ApiTraits>& x) noexcept -> const
58  typename std::tuple_element<I, basic_egl_api<ApiTraits>>::type& {
59  return x;
60 }
61 //------------------------------------------------------------------------------
62 } // namespace eagine::eglp
63 
64 // NOLINTNEXTLINE(cert-dcl58-cpp)
65 namespace std {
66 //------------------------------------------------------------------------------
67 template <typename ApiTraits>
68 struct tuple_size<eagine::eglp::basic_egl_api<ApiTraits>>
69  : public std::integral_constant<std::size_t, 2> {};
70 
71 template <typename ApiTraits>
72 struct tuple_element<0, eagine::eglp::basic_egl_api<ApiTraits>> {
74 };
75 
76 template <typename ApiTraits>
77 struct tuple_element<1, eagine::eglp::basic_egl_api<ApiTraits>> {
79 };
80 //------------------------------------------------------------------------------
81 } // namespace std
82 
83 #endif // EGLPLUS_BASIC_EGL_API_HPP
EGL-related code is placed in this namespace.
Definition: eglplus.hpp:11
Class wrapping the functions from the EGL API.
Definition: api.hpp:37
Common code is placed in this namespace.
Definition: eagine.hpp:21
Class wrapping the constants from the EGL API.
Definition: constants.hpp:21

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).