VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Common/Core/vtkAutoInit.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkAutoInit.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 #ifndef vtkAutoInit_h
00016 #define vtkAutoInit_h
00017 
00018 #include "vtkDebugLeaksManager.h" // DebugLeaks exists longer.
00019 #include "vtkTimeStamp.h" // Here so that TimeStamp Schwarz initializer works
00020 
00021 #define VTK_AUTOINIT(M) VTK_AUTOINIT0(M,M##_AUTOINIT)
00022 #define VTK_AUTOINIT0(M,T) VTK_AUTOINIT1(M,T)
00023 #define VTK_AUTOINIT1(M,T)                                              \
00024   /* Declare every <mod>_AutoInit_(Construct|Destruct) function.  */    \
00025   VTK_AUTOINIT_DECLARE_##T                                              \
00026   static struct M##_AutoInit {                                          \
00027     /* Call every <mod>_AutoInit_Construct during initialization.  */   \
00028     M##_AutoInit()  { VTK_AUTOINIT_CONSTRUCT_##T }                      \
00029     /* Call every <mod>_AutoInit_Destruct during finalization.  */      \
00030     ~M##_AutoInit() { VTK_AUTOINIT_DESTRUCT_##T  }                      \
00031   } M##_AutoInit_Instance;
00032 
00033 #define VTK_AUTOINIT_DECLARE_0()
00034 #define VTK_AUTOINIT_DECLARE_1(t1) VTK_AUTOINIT_DECLARE_0() VTK_AUTOINIT_DECLARE(t1)
00035 #define VTK_AUTOINIT_DECLARE_2(t1,t2) VTK_AUTOINIT_DECLARE_1(t1) VTK_AUTOINIT_DECLARE(t2)
00036 #define VTK_AUTOINIT_DECLARE_3(t1,t2,t3) VTK_AUTOINIT_DECLARE_2(t1,t2) VTK_AUTOINIT_DECLARE(t3)
00037 #define VTK_AUTOINIT_DECLARE_4(t1,t2,t3,t4) VTK_AUTOINIT_DECLARE_3(t1,t2,t3) VTK_AUTOINIT_DECLARE(t4)
00038 #define VTK_AUTOINIT_DECLARE_5(t1,t2,t3,t4,t5) VTK_AUTOINIT_DECLARE_4(t1,t2,t3,t4) VTK_AUTOINIT_DECLARE(t5)
00039 #define VTK_AUTOINIT_DECLARE_6(t1,t2,t3,t4,t5,t6) VTK_AUTOINIT_DECLARE_5(t1,t2,t3,t4,t5) VTK_AUTOINIT_DECLARE(t6)
00040 #define VTK_AUTOINIT_DECLARE_7(t1,t2,t3,t4,t5,t6,t7) VTK_AUTOINIT_DECLARE_6(t1,t2,t3,t4,t5,t6) VTK_AUTOINIT_DECLARE(t7)
00041 #define VTK_AUTOINIT_DECLARE_8(t1,t2,t3,t4,t5,t6,t7,t8) VTK_AUTOINIT_DECLARE_7(t1,t2,t3,t4,t5,t6,t7) VTK_AUTOINIT_DECLARE(t8)
00042 #define VTK_AUTOINIT_DECLARE_9(t1,t2,t3,t4,t5,t6,t7,t8,t9) VTK_AUTOINIT_DECLARE_8(t1,t2,t3,t4,t5,t6,t7,t8) VTK_AUTOINIT_DECLARE(t9)
00043 #define VTK_AUTOINIT_DECLARE(M) \
00044   void M##_AutoInit_Construct(); \
00045   void M##_AutoInit_Destruct();
00046 
00047 #define VTK_AUTOINIT_CONSTRUCT_0()
00048 #define VTK_AUTOINIT_CONSTRUCT_1(t1) VTK_AUTOINIT_CONSTRUCT_0() VTK_AUTOINIT_CONSTRUCT(t1)
00049 #define VTK_AUTOINIT_CONSTRUCT_2(t1,t2) VTK_AUTOINIT_CONSTRUCT_1(t1) VTK_AUTOINIT_CONSTRUCT(t2)
00050 #define VTK_AUTOINIT_CONSTRUCT_3(t1,t2,t3) VTK_AUTOINIT_CONSTRUCT_2(t1,t2) VTK_AUTOINIT_CONSTRUCT(t3)
00051 #define VTK_AUTOINIT_CONSTRUCT_4(t1,t2,t3,t4) VTK_AUTOINIT_CONSTRUCT_3(t1,t2,t3) VTK_AUTOINIT_CONSTRUCT(t4)
00052 #define VTK_AUTOINIT_CONSTRUCT_5(t1,t2,t3,t4,t5) VTK_AUTOINIT_CONSTRUCT_4(t1,t2,t3,t4) VTK_AUTOINIT_CONSTRUCT(t5)
00053 #define VTK_AUTOINIT_CONSTRUCT_6(t1,t2,t3,t4,t5,t6) VTK_AUTOINIT_CONSTRUCT_5(t1,t2,t3,t4,t5) VTK_AUTOINIT_CONSTRUCT(t6)
00054 #define VTK_AUTOINIT_CONSTRUCT_7(t1,t2,t3,t4,t5,t6,t7) VTK_AUTOINIT_CONSTRUCT_6(t1,t2,t3,t4,t5,t6) VTK_AUTOINIT_CONSTRUCT(t7)
00055 #define VTK_AUTOINIT_CONSTRUCT_8(t1,t2,t3,t4,t5,t6,t7,t8) VTK_AUTOINIT_CONSTRUCT_7(t1,t2,t3,t4,t5,t6,t7) VTK_AUTOINIT_CONSTRUCT(t8)
00056 #define VTK_AUTOINIT_CONSTRUCT_9(t1,t2,t3,t4,t5,t6,t7,t8,t9) VTK_AUTOINIT_CONSTRUCT_8(t1,t2,t3,t4,t5,t6,t7,t8) VTK_AUTOINIT_CONSTRUCT(t9)
00057 #define VTK_AUTOINIT_CONSTRUCT(M) \
00058   M##_AutoInit_Construct();
00059 
00060 #define VTK_AUTOINIT_DESTRUCT_0()
00061 #define VTK_AUTOINIT_DESTRUCT_1(t1) VTK_AUTOINIT_DESTRUCT_0() VTK_AUTOINIT_DESTRUCT(t1)
00062 #define VTK_AUTOINIT_DESTRUCT_2(t1,t2) VTK_AUTOINIT_DESTRUCT_1(t1) VTK_AUTOINIT_DESTRUCT(t2)
00063 #define VTK_AUTOINIT_DESTRUCT_3(t1,t2,t3) VTK_AUTOINIT_DESTRUCT_2(t1,t2) VTK_AUTOINIT_DESTRUCT(t3)
00064 #define VTK_AUTOINIT_DESTRUCT_4(t1,t2,t3,t4) VTK_AUTOINIT_DESTRUCT_3(t1,t2,t3) VTK_AUTOINIT_DESTRUCT(t4)
00065 #define VTK_AUTOINIT_DESTRUCT_5(t1,t2,t3,t4,t5) VTK_AUTOINIT_DESTRUCT_4(t1,t2,t3,t4) VTK_AUTOINIT_DESTRUCT(t5)
00066 #define VTK_AUTOINIT_DESTRUCT_6(t1,t2,t3,t4,t5,t6) VTK_AUTOINIT_DESTRUCT_5(t1,t2,t3,t4,t5) VTK_AUTOINIT_DESTRUCT(t6)
00067 #define VTK_AUTOINIT_DESTRUCT_7(t1,t2,t3,t4,t5,t6,t7) VTK_AUTOINIT_DESTRUCT_6(t1,t2,t3,t4,t5,t6) VTK_AUTOINIT_DESTRUCT(t7)
00068 #define VTK_AUTOINIT_DESTRUCT_8(t1,t2,t3,t4,t5,t6,t7,t8) VTK_AUTOINIT_DESTRUCT_7(t1,t2,t3,t4,t5,t6,t7) VTK_AUTOINIT_DESTRUCT(t8)
00069 #define VTK_AUTOINIT_DESTRUCT_9(t1,t2,t3,t4,t5,t6,t7,t8,t9) VTK_AUTOINIT_DESTRUCT_8(t1,t2,t3,t4,t5,t6,t7,t8) VTK_AUTOINIT_DESTRUCT(t9)
00070 #define VTK_AUTOINIT_DESTRUCT(M) \
00071   M##_AutoInit_Destruct();
00072 
00073 // Description:
00074 // Initialize the named module, ensuring its object factory is correctly
00075 // registered and unregistered. This call must be made in global scope in the
00076 // translation unit of your executable (which can include a shared library, but
00077 // will not work as expected in a static library).
00078 //
00079 // @code{.cpp}
00080 // #include "vtkAutoInit.h"
00081 // VTK_MODULE_INIT(vtkRenderingOpenGL);
00082 // @endcode
00083 //
00084 // The above snippet if included in the global scope will ensure the object
00085 // factories for vtkRenderingOpenGL are correctly registered and unregistered.
00086 #define VTK_MODULE_INIT(M) \
00087   VTK_AUTOINIT_DECLARE(M) \
00088   static struct M##_ModuleInit {                                           \
00089     /* Call <mod>_AutoInit_Construct during initialization.  */            \
00090     M##_ModuleInit()  { VTK_AUTOINIT_CONSTRUCT(M) }                      \
00091     /* Call <mod>_AutoInit_Destruct during finalization.  */               \
00092     ~M##_ModuleInit() { VTK_AUTOINIT_DESTRUCT(M)  }                      \
00093   } M##_ModuleInit_Instance;
00094 
00095 
00096 #endif
00097 // VTK-HeaderTest-Exclude: vtkAutoInit.h