glbinding  2.1.1.000000000000
A C++ binding for the OpenGL API, generated using the gl.xml specification.
Function.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <functional>
5 
7 
8 #ifndef WINAPI
9 #ifdef SYSTEM_WINDOWS
10 #define WINAPI __stdcall
11 #else
12 #define WINAPI
13 #endif
14 #endif
15 
16 
17 namespace glbinding
18 {
19 
20 
30 template <typename ReturnType, typename... Arguments>
32 {
33  using type = std::function<void(ReturnType, Arguments...)>;
34 };
35 
43 template <typename... Arguments>
44 struct CallbackType<void, Arguments...>
45 {
46  using type = std::function<void(Arguments...)>;
47 };
48 
61 template <typename ReturnType, typename... Arguments>
62 class Function : public AbstractFunction
63 {
64 public:
65  using Signature = ReturnType(WINAPI *) (Arguments...);
66 
67  using BeforeCallback = typename CallbackType<void, Arguments...>::type;
68  using AfterCallback = typename CallbackType<ReturnType, Arguments...>::type;
69 
70 public:
78  Function(const char * name);
79 
92  ReturnType operator()(Arguments&... arguments) const;
93 
106  ReturnType call(Arguments&... arguments) const;
107 
120  ReturnType directCall(Arguments... arguments) const;
121 
131  void setBeforeCallback(BeforeCallback callback);
132 
137  void clearBeforeCallback();
138 
148  void setAfterCallback(AfterCallback callback);
149 
154  void clearAfterCallback();
155 
164 
173 
174 protected:
177 };
178 
179 
180 } // namespace glbinding
181 
182 
183 #include <glbinding/Function.inl>
const char * name() const
Name accessor.
std::function< void(Arguments...)> type
Propagate the actual callable callback type.
Definition: Function.h:46
void(WINAPI *)(Arguments...) Signature
The c pointer type for a function call.
Definition: Function.h:65
void setBeforeCallback(BeforeCallback callback)
Register a callback that is triggered before a function call to the OpenGL driver.
Definition: Function.inl:183
typename CallbackType< void, Arguments... >::type AfterCallback
The callback type for the after callback.
Definition: Function.h:68
BeforeCallback beforeCallback() const
The accessor for the beforeCallback.
Definition: Function.inl:207
ReturnType operator()(Arguments &... arguments) const
Executes a function call on the resolved function pointer and passes the arguments.
Definition: Function.inl:146
void clearBeforeCallback()
Clears any previously registered before callback.
Definition: Function.inl:189
std::function< void(ReturnType, Arguments...)> type
Propagate the actual callable callback type.
Definition: Function.h:33
BeforeCallback m_beforeCallback
The currently registered before callback.
Definition: Function.h:175
Function(const char *name)
Constructor.
Definition: Function.inl:138
void setAfterCallback(AfterCallback callback)
Register a callback that is triggered after a function call to the OpenGL driver.
Definition: Function.inl:195
A callback signature with return type and multiple arguments.
Definition: Function.h:31
AfterCallback m_afterCallback
The currently registered after callback.
Definition: Function.h:176
#define WINAPI
Definition: Function.h:12
AfterCallback afterCallback() const
The accessor for the afterCallback.
Definition: Function.inl:213
Contains all the classes of glbinding.
The AbstractFunction represents an OpenGL API function.
Definition: AbstractFunction.h:23
void clearAfterCallback()
Clears any previously registered after callback.
Definition: Function.inl:201
The Function represents an OpenGL API function with additional features, including:
Definition: Function.h:62
typename CallbackType< void, Arguments... >::type BeforeCallback
The callback type for the before callback.
Definition: Function.h:67
ReturnType directCall(Arguments... arguments) const
Executes a function call on the resolved function pointer and passes the arguments.
Definition: Function.inl:177
ReturnType call(Arguments &... arguments) const
Executes a function call on the resolved function pointer and passes the arguments.
Definition: Function.inl:152