]> Creatis software - gdcm.git/blob - src/gdcmMacro.h
Fix mistypings
[gdcm.git] / src / gdcmMacro.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmMacro.h,v $
5   Language:  C++
6   Date:      $Date: 2007/08/22 16:14:04 $
7   Version:   $Revision: 1.7 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 #ifndef _GDCMMACRO_H_
20 #define _GDCMMACRO_H_
21
22 //-----------------------------------------------------------------------------
23 #define gdcmTypeMacro(type)               \
24    private :                              \
25       type(type &); /* Not implemented */ \
26       type &operator=(type &) /* Not implemented */
27
28 #define gdcmNewMacro(type)                \
29    public :                               \
30       static type *New() {return new type(); } /* Not implemented */
31
32 //-----------------------------------------------------------------------------
33 //
34 // Define GDCM_LEGACY macro to mark legacy methods where they are
35 // declared in their class.
36 //
37 // WARNING : Don't try to use it with 'inline' methods !
38 //
39 //Example usage:
40 //
41 //   // @deprecated Replaced by MyOtherMethod() as of gdcm 2.0.
42 //   GDCM_LEGACY(void MyMethod())
43 #if defined(GDCM_LEGACY_REMOVE)
44   // Remove legacy methods completely.
45 # define GDCM_LEGACY(method)
46 #elif defined(GDCM_LEGACY_SILENT)
47   // Provide legacy methods with no warnings.
48 # define GDCM_LEGACY(method) method;
49 #else
50   // Setup compile-time warnings for uses of deprecated methods if
51   // possible on this compiler.
52 # if defined(__GNUC__) && !defined(__INTEL_COMPILER) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
53 #if defined(__APPLE__) && (__GNUC__ == 3) && (__GNUC_MINOR__ == 3)
54 // Seems like there is a bug in APPLE gcc for deprecated attribute and ctor
55 // This is fixed in g++ 4.0 (Tiger)
56 #  define GDCM_LEGACY(method) method;
57 #else
58 #  define GDCM_LEGACY(method) method __attribute__((deprecated));
59 #endif
60 # elif defined(_MSC_VER) && _MSC_VER >= 1300
61 #  define GDCM_LEGACY(method) __declspec(deprecated) method;
62 # else
63 #  define GDCM_LEGACY(method) method;
64 # endif
65 #endif
66
67 // Macros to create runtime deprecation warning messages in function
68 // bodies.  Example usage:
69 //
70 //   void MyClass::MyOldMethod()
71 //   {
72 //     GDCM_LEGACY_BODY(MyClass::MyOldMethod, 2.0);
73 //   }
74 //
75 //   void MyClass::MyMethod()
76 //   {
77 //     GDCM_LEGACY_REPLACED_BODY(MyClass::MyMethod, 5.0,
78 //                               MyClass::MyOtherMethod);
79 //   }
80 #if defined(GDCM_LEGACY_REMOVE) || defined(GDCM_LEGACY_SILENT)
81 # define GDCM_LEGACY_BODY(method, version)
82 # define GDCM_LEGACY_REPLACED_BODY(method, version, replace)
83 #else
84 # define GDCM_LEGACY_BODY(method, version) \
85   gdcmWarningMacro(#method " was deprecated for gdcm" #version " and will be removed in a future version.")
86 # define GDCM_LEGACY_REPLACED_BODY(method, version, replace) \
87   gdcmWarningMacro(#method " was deprecated for gdcm" #version " and will be removed in a future version.  Use " #replace " instead.")
88 #endif
89
90 //-----------------------------------------------------------------------------
91 #endif