Mercurial > hg > orthanc
comparison OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h @ 5575:d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 26 Apr 2024 17:17:34 +0200 |
parents | f0dc99bc811c |
children | f7adfb22e20e |
comparison
equal
deleted
inserted
replaced
5573:823aae1ea72a | 5575:d7eaa568da15 |
---|---|
51 (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER == minor && \ | 51 (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER == minor && \ |
52 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER >= revision)))) | 52 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER >= revision)))) |
53 #endif | 53 #endif |
54 | 54 |
55 | 55 |
56 #if !defined(ORTHANC_FRAMEWORK_VERSION_IS_ABOVE) | |
57 #define ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(major, minor, revision) \ | |
58 (ORTHANC_VERSION_MAJOR > major || \ | |
59 (ORTHANC_VERSION_MAJOR == major && \ | |
60 (ORTHANC_VERSION_MINOR > minor || \ | |
61 (ORTHANC_VERSION_MINOR == minor && \ | |
62 ORTHANC_VERSION_REVISION >= revision)))) | |
63 #endif | |
64 | |
65 | |
56 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 2, 0) | 66 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 2, 0) |
57 // The "OrthancPluginFindMatcher()" primitive was introduced in Orthanc 1.2.0 | 67 // The "OrthancPluginFindMatcher()" primitive was introduced in Orthanc 1.2.0 |
58 # define HAS_ORTHANC_PLUGIN_FIND_MATCHER 1 | 68 # define HAS_ORTHANC_PLUGIN_FIND_MATCHER 1 |
59 #else | 69 #else |
60 # define HAS_ORTHANC_PLUGIN_FIND_MATCHER 0 | 70 # define HAS_ORTHANC_PLUGIN_FIND_MATCHER 0 |
115 # define HAS_ORTHANC_PLUGIN_WEBDAV 1 | 125 # define HAS_ORTHANC_PLUGIN_WEBDAV 1 |
116 #else | 126 #else |
117 # define HAS_ORTHANC_PLUGIN_WEBDAV 0 | 127 # define HAS_ORTHANC_PLUGIN_WEBDAV 0 |
118 #endif | 128 #endif |
119 | 129 |
120 | 130 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4) |
121 // Macro "ORTHANC_PLUGINS_DEPRECATED" tags a function as having been deprecated | 131 # define HAS_ORTHANC_PLUGIN_LOG_MESSAGE 1 |
132 #else | |
133 # define HAS_ORTHANC_PLUGIN_LOG_MESSAGE 0 | |
134 #endif | |
135 | |
136 | |
137 // Macro to tag a function as having been deprecated | |
122 #if (__cplusplus >= 201402L) // C++14 | 138 #if (__cplusplus >= 201402L) // C++14 |
123 # define ORTHANC_PLUGINS_DEPRECATED(f) [[deprecated]] f | 139 # define ORTHANC_PLUGIN_CPP_WRAPPER_DEPRECATED(f) [[deprecated]] f |
124 #elif defined(__GNUC__) || defined(__clang__) | 140 #elif defined(__GNUC__) || defined(__clang__) |
125 # define ORTHANC_PLUGINS_DEPRECATED(f) f __attribute__((deprecated)) | 141 # define ORTHANC_PLUGIN_CPP_WRAPPER_DEPRECATED(f) f __attribute__((deprecated)) |
126 #elif defined(_MSC_VER) | 142 #elif defined(_MSC_VER) |
127 # define ORTHANC_PLUGINS_DEPRECATED(f) __declspec(deprecated) f | 143 # define ORTHANC_PLUGIN_CPP_WRAPPER_DEPRECATED(f) __declspec(deprecated) f |
128 #else | 144 #else |
129 # define ORTHANC_PLUGINS_DEPRECATED | 145 # define ORTHANC_PLUGIN_CPP_WRAPPER_DEPRECATED |
130 #endif | 146 #endif |
131 | 147 |
132 | 148 |
133 #if !defined(__ORTHANC_FILE__) | 149 #if !defined(__ORTHANC_FILE__) |
134 # if defined(_MSC_VER) | 150 # if defined(_MSC_VER) |
137 # warning Warning: Macro __ORTHANC_FILE__ is not defined, this will leak the full path of the source files in the binaries | 153 # warning Warning: Macro __ORTHANC_FILE__ is not defined, this will leak the full path of the source files in the binaries |
138 # endif | 154 # endif |
139 # define __ORTHANC_FILE__ __FILE__ | 155 # define __ORTHANC_FILE__ __FILE__ |
140 #endif | 156 #endif |
141 | 157 |
142 #define ORTHANC_PLUGINS_LOG_ERROR(msg) ::OrthancPlugins::LogMessage(OrthancPluginLogLevel_Error, __ORTHANC_FILE__, __LINE__, msg); | 158 |
143 #define ORTHANC_PLUGINS_LOG_WARNING(msg) ::OrthancPlugins::LogMessage(OrthancPluginLogLevel_Warning, __ORTHANC_FILE__, __LINE__, msg); | 159 #if HAS_ORTHANC_PLUGIN_LOG_MESSAGE == 1 |
144 #define ORTHANC_PLUGINS_LOG_INFO(msg) ::OrthancPlugins::LogMessage(OrthancPluginLogLevel_Info, __ORTHANC_FILE__, __LINE__, msg); | 160 # define ORTHANC_PLUGINS_LOG_ERROR(msg) ::OrthancPlugins::LogMessage(OrthancPluginLogLevel_Error, __ORTHANC_FILE__, __LINE__, msg) |
161 # define ORTHANC_PLUGINS_LOG_WARNING(msg) ::OrthancPlugins::LogMessage(OrthancPluginLogLevel_Warning, __ORTHANC_FILE__, __LINE__, msg) | |
162 # define ORTHANC_PLUGINS_LOG_INFO(msg) ::OrthancPlugins::LogMessage(OrthancPluginLogLevel_Info, __ORTHANC_FILE__, __LINE__, msg) | |
163 #else | |
164 # define ORTHANC_PLUGINS_LOG_ERROR(msg) ::OrthancPlugins::LogError(msg) | |
165 # define ORTHANC_PLUGINS_LOG_WARNING(msg) ::OrthancPlugins::LogWarning(msg) | |
166 # define ORTHANC_PLUGINS_LOG_INFO(msg) ::OrthancPlugins::LogInfo(msg) | |
167 #endif | |
145 | 168 |
146 | 169 |
147 namespace OrthancPlugins | 170 namespace OrthancPlugins |
148 { | 171 { |
149 typedef void (*RestCallback) (OrthancPluginRestOutput* output, | 172 typedef void (*RestCallback) (OrthancPluginRestOutput* output, |
653 | 676 |
654 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 0) | 677 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 0) |
655 const char* AutodetectMimeType(const std::string& path); | 678 const char* AutodetectMimeType(const std::string& path); |
656 #endif | 679 #endif |
657 | 680 |
681 #if HAS_ORTHANC_PLUGIN_LOG_MESSAGE == 1 | |
658 void LogMessage(OrthancPluginLogLevel level, | 682 void LogMessage(OrthancPluginLogLevel level, |
659 const char* file, | 683 const char* file, |
660 uint32_t line, | 684 uint32_t line, |
661 const std::string& message); | 685 const std::string& message); |
662 | 686 #endif |
687 | |
688 #if HAS_ORTHANC_PLUGIN_LOG_MESSAGE == 1 | |
663 // Use macro ORTHANC_PLUGINS_LOG_ERROR() instead | 689 // Use macro ORTHANC_PLUGINS_LOG_ERROR() instead |
664 ORTHANC_PLUGINS_DEPRECATED(void LogError(const std::string& message)); | 690 ORTHANC_PLUGIN_CPP_WRAPPER_DEPRECATED(void LogError(const std::string& message)); |
665 | 691 #else |
692 void LogError(const std::string& message); | |
693 #endif | |
694 | |
695 #if HAS_ORTHANC_PLUGIN_LOG_MESSAGE == 1 | |
666 // Use macro ORTHANC_PLUGINS_LOG_WARNING() instead | 696 // Use macro ORTHANC_PLUGINS_LOG_WARNING() instead |
667 ORTHANC_PLUGINS_DEPRECATED(void LogWarning(const std::string& message)); | 697 ORTHANC_PLUGIN_CPP_WRAPPER_DEPRECATED(void LogWarning(const std::string& message)); |
668 | 698 #else |
699 void LogWarning(const std::string& message); | |
700 #endif | |
701 | |
702 #if HAS_ORTHANC_PLUGIN_LOG_MESSAGE == 1 | |
669 // Use macro ORTHANC_PLUGINS_LOG_INFO() instead | 703 // Use macro ORTHANC_PLUGINS_LOG_INFO() instead |
670 ORTHANC_PLUGINS_DEPRECATED(void LogInfo(const std::string& message)); | 704 ORTHANC_PLUGIN_CPP_WRAPPER_DEPRECATED(void LogInfo(const std::string& message)); |
705 #else | |
706 void LogInfo(const std::string& message); | |
707 #endif | |
671 | 708 |
672 void ReportMinimalOrthancVersion(unsigned int major, | 709 void ReportMinimalOrthancVersion(unsigned int major, |
673 unsigned int minor, | 710 unsigned int minor, |
674 unsigned int revision); | 711 unsigned int revision); |
675 | 712 |