iMSTK
Interactive Medical Simulation Toolkit
imstkMacros.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 namespace imstk
10 {
11 #define imstkNotUsed(x)
12 
13 #define imstkSetMacro(name, dataType) \
14  virtual void set ## name(dataType _arg) \
15  { \
16  if (this->m_ ## name != _arg) \
17  { \
18  this->m_ ## name = _arg; \
19  } \
20  }
21 #define imstkGetMacro(name, dataType) \
22  virtual dataType get ## name() { return this->m_ ## name; }
23 
24 #define IMSTK_TYPE_NAME(name) \
25  static const std::string getStaticTypeName() { return #name; } \
26  const std::string getTypeName() const override { return #name; }
27 
28 // \todo Switch to template type lists
32 #define TemplateMacroCase(typeN, type, call) \
33 case typeN: { using IMSTK_TT = type; call; }; break
34 #define TemplateMacro(call) \
35  TemplateMacroCase(IMSTK_CHAR, char, call); \
36  TemplateMacroCase(IMSTK_UNSIGNED_CHAR, unsigned char, call); \
37  TemplateMacroCase(IMSTK_SHORT, short, call); \
38  TemplateMacroCase(IMSTK_UNSIGNED_SHORT, unsigned short, call); \
39  TemplateMacroCase(IMSTK_INT, int, call); \
40  TemplateMacroCase(IMSTK_UNSIGNED_INT, unsigned int, call); \
41  TemplateMacroCase(IMSTK_LONG, long, call); \
42  TemplateMacroCase(IMSTK_UNSIGNED_LONG, unsigned long, call); \
43  TemplateMacroCase(IMSTK_FLOAT, float, call); \
44  TemplateMacroCase(IMSTK_DOUBLE, double, call); \
45  TemplateMacroCase(IMSTK_LONG_LONG, long long, call); \
46  TemplateMacroCase(IMSTK_UNSIGNED_LONG_LONG, unsigned long long, call)
47 
51 #define TypeTemplateMacro(templateType) \
52  (std::is_same<templateType, char>::value ? IMSTK_CHAR : \
53  (std::is_same<templateType, unsigned char>::value ? IMSTK_UNSIGNED_CHAR : \
54  (std::is_same<templateType, short>::value ? IMSTK_SHORT : \
55  (std::is_same<templateType, unsigned short>::value ? IMSTK_UNSIGNED_SHORT : \
56  (std::is_same<templateType, int>::value ? IMSTK_INT : \
57  (std::is_same<templateType, unsigned int>::value ? IMSTK_UNSIGNED_INT : \
58  (std::is_same<templateType, long>::value ? IMSTK_LONG : \
59  (std::is_same<templateType, unsigned long>::value ? IMSTK_UNSIGNED_LONG : \
60  (std::is_same<templateType, float>::value ? IMSTK_FLOAT : \
61  (std::is_same<templateType, double>::value ? IMSTK_DOUBLE : \
62  (std::is_same<templateType, long long>::value ? IMSTK_LONG_LONG : \
63  (std::is_same<templateType, unsigned long long>::value ? IMSTK_UNSIGNED_LONG_LONG : 0))))))))))))
64 } // namespace imstk
65 
66 // See https://www.fluentcpp.com/2019/08/30/how-to-disable-a-warning-in-cpp/
67 // When adding new warnings remember to add the DISABLE_ macro
68 // for all three sections MSVC, GCC/CLANG, other
69 #if defined(_MSC_VER)
70 #define DISABLE_WARNING_PUSH __pragma(warning( push ))
71 #define DISABLE_WARNING_POP __pragma(warning( pop ))
72 #define DISABLE_WARNING(warningNumber) __pragma(warning( disable : warningNumber ))
73 
74 #define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER DISABLE_WARNING(4100)
75 #define DISABLE_WARNING_UNREFERENCED_FUNCTION DISABLE_WARNING(4505)
76 #define DISABLE_WARNING_HIDES_CLASS_MEMBER DISABLE_WARNING(4458)
77 #define DISABLE_WARNING_PADDING DISABLE_WARNING(4324)
78 // other warnings you want to deactivate...
79 
80 // Not seen in msvc or not checked, fix when working with windows
81 
82 #elif defined(__GNUC__) || defined(__clang__)
83 #define DO_PRAGMA(X) _Pragma(#X)
84 #define DISABLE_WARNING_PUSH DO_PRAGMA(GCC diagnostic push)
85 #define DISABLE_WARNING_POP DO_PRAGMA(GCC diagnostic pop)
86 #define DISABLE_WARNING(warningName) DO_PRAGMA(GCC diagnostic ignored #warningName)
87 
88 #define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER DISABLE_WARNING(-Wunused - parameter)
89 #define DISABLE_WARNING_UNREFERENCED_FUNCTION DISABLE_WARNING(-Wunused - function)
90 // other warnings you want to deactivate...
91 
92 // Not seen in gcc or not checked, fix when working with linux
93 #define DISABLE_WARNING_HIDES_CLASS_MEMBER
94 #define DISABLE_WARNING_PADDING
95 
96 #else
97 #define DISABLE_WARNING_PUSH
98 #define DISABLE_WARNING_POP
99 #define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER
100 #define DISABLE_WARNING_UNREFERENCED_FUNCTION
101 #define DISABLE_WARNING_HIDES_CLASS_MEMBER
102 // other warnings you want to deactivate...
103 
104 #endif
Compound Geometry.