Mercurial > hg > orthanc
diff OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h @ 5572:f0dc99bc811c
removed circular dependency of OrthancPluginsCppWrapper with Orthanc::Logging
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 26 Apr 2024 15:50:01 +0200 |
parents | 0b18690c1935 |
children | d7eaa568da15 |
line wrap: on
line diff
--- a/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h Fri Apr 26 14:48:11 2024 +0200 +++ b/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h Fri Apr 26 15:50:01 2024 +0200 @@ -53,16 +53,6 @@ #endif -#if !defined(ORTHANC_FRAMEWORK_VERSION_IS_ABOVE) -#define ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(major, minor, revision) \ - (ORTHANC_VERSION_MAJOR > major || \ - (ORTHANC_VERSION_MAJOR == major && \ - (ORTHANC_VERSION_MINOR > minor || \ - (ORTHANC_VERSION_MINOR == minor && \ - ORTHANC_VERSION_REVISION >= revision)))) -#endif - - #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 2, 0) // The "OrthancPluginFindMatcher()" primitive was introduced in Orthanc 1.2.0 # define HAS_ORTHANC_PLUGIN_FIND_MATCHER 1 @@ -128,6 +118,31 @@ #endif +// Macro "ORTHANC_PLUGINS_DEPRECATED" tags a function as having been deprecated +#if (__cplusplus >= 201402L) // C++14 +# define ORTHANC_PLUGINS_DEPRECATED(f) [[deprecated]] f +#elif defined(__GNUC__) || defined(__clang__) +# define ORTHANC_PLUGINS_DEPRECATED(f) f __attribute__((deprecated)) +#elif defined(_MSC_VER) +# define ORTHANC_PLUGINS_DEPRECATED(f) __declspec(deprecated) f +#else +# define ORTHANC_PLUGINS_DEPRECATED +#endif + + +#if !defined(__ORTHANC_FILE__) +# if defined(_MSC_VER) +# pragma message("Warning: Macro __ORTHANC_FILE__ is not defined, this will leak the full path of the source files in the binaries") +# else +# warning Warning: Macro __ORTHANC_FILE__ is not defined, this will leak the full path of the source files in the binaries +# endif +# define __ORTHANC_FILE__ __FILE__ +#endif + +#define ORTHANC_PLUGINS_LOG_ERROR(msg) ::OrthancPlugins::LogMessage(OrthancPluginLogLevel_Error, __ORTHANC_FILE__, __LINE__, msg); +#define ORTHANC_PLUGINS_LOG_WARNING(msg) ::OrthancPlugins::LogMessage(OrthancPluginLogLevel_Warning, __ORTHANC_FILE__, __LINE__, msg); +#define ORTHANC_PLUGINS_LOG_INFO(msg) ::OrthancPlugins::LogMessage(OrthancPluginLogLevel_Info, __ORTHANC_FILE__, __LINE__, msg); + namespace OrthancPlugins { @@ -137,9 +152,8 @@ void SetGlobalContext(OrthancPluginContext* context); -#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4) && ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 12, 4) - void SetGlobalContext(OrthancPluginContext* context, const char* pluginName); -#endif + void SetGlobalContext(OrthancPluginContext* context, + const char* pluginName); void ResetGlobalContext(); @@ -641,11 +655,19 @@ const char* AutodetectMimeType(const std::string& path); #endif - void LogError(const std::string& message); // From Orthanc 1.12.4, use LOG(ERROR) to display the plugin name, file and line (First set a plugin name in Orthanc::Logging::InitializePluginContext) + void LogMessage(OrthancPluginLogLevel level, + const char* file, + uint32_t line, + const std::string& message); - void LogWarning(const std::string& message); // From Orthanc 1.12.4, use LOG(WARNING) to display the plugin name, file and line (First set a plugin name in Orthanc::Logging::InitializePluginContext) + // Use macro ORTHANC_PLUGINS_LOG_ERROR() instead + ORTHANC_PLUGINS_DEPRECATED(void LogError(const std::string& message)); - void LogInfo(const std::string& message); // From Orthanc 1.12.4, use LOG(INFO) to display the plugin name, file and line (First set a plugin name in Orthanc::Logging::InitializePluginContext) + // Use macro ORTHANC_PLUGINS_LOG_WARNING() instead + ORTHANC_PLUGINS_DEPRECATED(void LogWarning(const std::string& message)); + + // Use macro ORTHANC_PLUGINS_LOG_INFO() instead + ORTHANC_PLUGINS_DEPRECATED(void LogInfo(const std::string& message)); void ReportMinimalOrthancVersion(unsigned int major, unsigned int minor,