AGX Dynamics  2.35.0.1
Initializer.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGX_INITIALIZER_H
18 #define AGX_INITIALIZER_H
19 
20 #include <agx/agx.h>
21 #include <agx/Integer.h>
22 #include <agx/Callback.h>
23 
24 namespace agx
25 {
34  #define AGX_STATIC_INITIALIZER() \
35  static void AGX_CONCAT(__agx_static_init, __LINE__)(void); \
36  static agx::StaticInitializer AGX_CONCAT(__agx_static_init_dispatch, __LINE__)(&AGX_CONCAT(__agx_static_init, __LINE__)); \
37  static void AGX_CONCAT(__agx_static_init, __LINE__)(void)
38 
39  // Do not use class directly
41  {
42  public:
43  typedef void (*Implementation)(void);
44 
45  StaticInitializer(Implementation implementation);
46  };
47 
48 
49  //-----------------------------------------------------------------------------------------------------
50  #define AGX_STATIC_SHUTDOWN() \
51  static void AGX_CONCAT(__agx_static_shutdown, __LINE__)(void); \
52  static agx::StaticShutdown AGX_CONCAT(__agx_static_shutdown_dispatch, __LINE__)(&AGX_CONCAT(__agx_static_shutdown, __LINE__)); \
53  static void AGX_CONCAT(__agx_static_shutdown, __LINE__)(void)
54 
55  // Do not use class directly
57  {
58  public:
59  typedef void (*Implementation)(void);
60 
61  StaticShutdown(Implementation implementation);
62  virtual ~StaticShutdown();
63 
64  private:
65  Implementation m_implementation;
66  };
67 
68 
74  #define AGX_INIT_CALLBACK() \
75  static void AGX_CONCAT(__agx_init_callback, __LINE__)(); \
76  static agx::InitCallback AGX_CONCAT(__agx_init_callback_dispatch, __LINE__)(&AGX_CONCAT(__agx_init_callback, __LINE__)); \
77  static void AGX_CONCAT(__agx_init_callback, __LINE__)()
78 
81  {
82  public:
83  using Implementation = void(*)();
84  explicit InitCallback(Implementation implementation);
85 
86  private:
87  friend void agxCore::init();
88  static void triggerInit();
89 
90  private:
91  Implementation m_implementation;
92  InitCallback* m_next;
93  };
94 
95 
96  //-----------------------------------------------------------------------------------------------------
97 
108  #define AGX_SHUTDOWN_CALLBACK() \
109  static void AGX_CONCAT(__agx_shutdown_callback, __LINE__)(void); \
110  static agx::ShutdownCallback AGX_CONCAT(__agx_shutdown_callback_dispatch, __LINE__)(&AGX_CONCAT(__agx_shutdown_callback, __LINE__)); \
111  static void AGX_CONCAT(__agx_shutdown_callback, __LINE__)(void)
112 
113 
114  // Do not use class directly
116  {
117  public:
118  typedef void (*Implementation)(void);
119 
120  ShutdownCallback(Implementation implementation);
121 
122  private:
123  friend void agxCore::shutdown();
124  static void triggerShutdown();
125 
126  private:
127  Implementation m_implementation;
128  ShutdownCallback *m_next;
129  };
130 
131 
132 }
133 
134 
135 
136 #endif /* _AGX_INITIALIZER_H_ */
#define AGXCORE_EXPORT
Do not use class directly. Use AGX_INIT_CALLBACK instead.
Definition: Initializer.h:81
InitCallback(Implementation implementation)
void(*)() Implementation
Definition: Initializer.h:83
ShutdownCallback(Implementation implementation)
StaticInitializer(Implementation implementation)
virtual ~StaticShutdown()
StaticShutdown(Implementation implementation)
void AGXCORE_EXPORT shutdown()
Shutdown the AGX API, after this call no AGX API calls should be done.
void AGXCORE_EXPORT init()
Deprecated, no need for explicit initialization.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.