VTK  9.1.0
vtkAutoInit.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkAutoInit.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
15#ifndef vtkAutoInit_h
16#define vtkAutoInit_h
17
18#include "vtkDebugLeaksManager.h" // DebugLeaks exists longer.
19#include "vtkTimeStamp.h" // Here so that TimeStamp Schwarz initializer works
20
21#define VTK_MODULE_AUTOINIT VTK_AUTOINIT
22
23#define VTK_AUTOINIT(M) VTK_AUTOINIT0(M, M##_AUTOINIT)
24#define VTK_AUTOINIT0(M, T) VTK_AUTOINIT1(M, T)
25#define VTK_AUTOINIT1(M, T) \
26 /* Declare every <mod>_AutoInit_Construct function. */ \
27 VTK_AUTOINIT_DECLARE_##T namespace \
28 { \
29 static struct M##_AutoInit \
30 { \
31 /* Call every <mod>_AutoInit_Construct during initialization. */ \
32 M##_AutoInit() { VTK_AUTOINIT_CONSTRUCT_##T } \
33 } M##_AutoInit_Instance; \
34 }
35
36#define VTK_AUTOINIT_DECLARE_0()
37#define VTK_AUTOINIT_DECLARE_1(t1) VTK_AUTOINIT_DECLARE_0() VTK_AUTOINIT_DECLARE(t1)
38#define VTK_AUTOINIT_DECLARE_2(t1, t2) VTK_AUTOINIT_DECLARE_1(t1) VTK_AUTOINIT_DECLARE(t2)
39#define VTK_AUTOINIT_DECLARE_3(t1, t2, t3) VTK_AUTOINIT_DECLARE_2(t1, t2) VTK_AUTOINIT_DECLARE(t3)
40#define VTK_AUTOINIT_DECLARE_4(t1, t2, t3, t4) \
41 VTK_AUTOINIT_DECLARE_3(t1, t2, t3) VTK_AUTOINIT_DECLARE(t4)
42#define VTK_AUTOINIT_DECLARE_5(t1, t2, t3, t4, t5) \
43 VTK_AUTOINIT_DECLARE_4(t1, t2, t3, t4) VTK_AUTOINIT_DECLARE(t5)
44#define VTK_AUTOINIT_DECLARE_6(t1, t2, t3, t4, t5, t6) \
45 VTK_AUTOINIT_DECLARE_5(t1, t2, t3, t4, t5) VTK_AUTOINIT_DECLARE(t6)
46#define VTK_AUTOINIT_DECLARE_7(t1, t2, t3, t4, t5, t6, t7) \
47 VTK_AUTOINIT_DECLARE_6(t1, t2, t3, t4, t5, t6) VTK_AUTOINIT_DECLARE(t7)
48#define VTK_AUTOINIT_DECLARE_8(t1, t2, t3, t4, t5, t6, t7, t8) \
49 VTK_AUTOINIT_DECLARE_7(t1, t2, t3, t4, t5, t6, t7) VTK_AUTOINIT_DECLARE(t8)
50#define VTK_AUTOINIT_DECLARE_9(t1, t2, t3, t4, t5, t6, t7, t8, t9) \
51 VTK_AUTOINIT_DECLARE_8(t1, t2, t3, t4, t5, t6, t7, t8) VTK_AUTOINIT_DECLARE(t9)
52#define VTK_AUTOINIT_DECLARE(M) void M##_AutoInit_Construct();
53
54#define VTK_AUTOINIT_CONSTRUCT_0()
55#define VTK_AUTOINIT_CONSTRUCT_1(t1) VTK_AUTOINIT_CONSTRUCT_0() VTK_AUTOINIT_CONSTRUCT(t1)
56#define VTK_AUTOINIT_CONSTRUCT_2(t1, t2) VTK_AUTOINIT_CONSTRUCT_1(t1) VTK_AUTOINIT_CONSTRUCT(t2)
57#define VTK_AUTOINIT_CONSTRUCT_3(t1, t2, t3) \
58 VTK_AUTOINIT_CONSTRUCT_2(t1, t2) VTK_AUTOINIT_CONSTRUCT(t3)
59#define VTK_AUTOINIT_CONSTRUCT_4(t1, t2, t3, t4) \
60 VTK_AUTOINIT_CONSTRUCT_3(t1, t2, t3) VTK_AUTOINIT_CONSTRUCT(t4)
61#define VTK_AUTOINIT_CONSTRUCT_5(t1, t2, t3, t4, t5) \
62 VTK_AUTOINIT_CONSTRUCT_4(t1, t2, t3, t4) VTK_AUTOINIT_CONSTRUCT(t5)
63#define VTK_AUTOINIT_CONSTRUCT_6(t1, t2, t3, t4, t5, t6) \
64 VTK_AUTOINIT_CONSTRUCT_5(t1, t2, t3, t4, t5) VTK_AUTOINIT_CONSTRUCT(t6)
65#define VTK_AUTOINIT_CONSTRUCT_7(t1, t2, t3, t4, t5, t6, t7) \
66 VTK_AUTOINIT_CONSTRUCT_6(t1, t2, t3, t4, t5, t6) VTK_AUTOINIT_CONSTRUCT(t7)
67#define VTK_AUTOINIT_CONSTRUCT_8(t1, t2, t3, t4, t5, t6, t7, t8) \
68 VTK_AUTOINIT_CONSTRUCT_7(t1, t2, t3, t4, t5, t6, t7) VTK_AUTOINIT_CONSTRUCT(t8)
69#define VTK_AUTOINIT_CONSTRUCT_9(t1, t2, t3, t4, t5, t6, t7, t8, t9) \
70 VTK_AUTOINIT_CONSTRUCT_8(t1, t2, t3, t4, t5, t6, t7, t8) VTK_AUTOINIT_CONSTRUCT(t9)
71#define VTK_AUTOINIT_CONSTRUCT(M) M##_AutoInit_Construct();
72
73// Description:
74// Initialize the named module, ensuring its object factory is correctly
75// registered. This call must be made in global scope in the
76// translation unit of your executable (which can include a shared library, but
77// will not work as expected in a static library).
78//
79// @code{.cpp}
80// #include "vtkAutoInit.h"
81// VTK_MODULE_INIT(vtkRenderingOpenGL2);
82// @endcode
83//
84// The above snippet if included in the global scope will ensure the object
85// factories for vtkRenderingOpenGL2 are correctly registered and unregistered.
86#define VTK_MODULE_INIT(M) \
87 VTK_AUTOINIT_DECLARE(M) namespace \
88 { \
89 static struct M##_ModuleInit \
90 { \
91 /* Call <mod>_AutoInit_Construct during initialization. */ \
92 M##_ModuleInit() { VTK_AUTOINIT_CONSTRUCT(M) } \
93 } M##_ModuleInit_Instance; \
94 }
95
96#endif
97// VTK-HeaderTest-Exclude: vtkAutoInit.h