# HG changeset patch # User Sebastien Jodogne # Date 1531388065 -7200 # Node ID 0bd1dfb14272ade8234c984b57917ce94c60c81e # Parent 73bc0c32547cc2056abe6f8a57c024a7c5e8f8d6 OrthancPluginCheckVersionAdvanced diff -r 73bc0c32547c -r 0bd1dfb14272 NEWS --- a/NEWS Mon Jul 09 13:02:56 2018 +0200 +++ b/NEWS Thu Jul 12 11:34:25 2018 +0200 @@ -40,6 +40,7 @@ ------- * New primitive in database SDK: "lookupIdentifierRange" to speed up range searches +* New function in the SDK: "OrthancPluginCheckVersionAdvanced()" Maintenance ----------- diff -r 73bc0c32547c -r 0bd1dfb14272 Plugins/Include/orthanc/OrthancCPlugin.h --- a/Plugins/Include/orthanc/OrthancCPlugin.h Mon Jul 09 13:02:56 2018 +0200 +++ b/Plugins/Include/orthanc/OrthancCPlugin.h Thu Jul 12 11:34:25 2018 +0200 @@ -1274,20 +1274,26 @@ /** - * @brief Check the compatibility of the plugin wrt. the version of its hosting Orthanc. + * @brief Check that the version of the hosting Orthanc is above a given version. * - * This function checks whether the version of this C header is - * compatible with the current version of Orthanc. The result of - * this function should always be checked in the - * OrthancPluginInitialize() entry point of the plugin. + * This function checks whether the version of the Orthanc server + * running this plugin, is above the given version. Contrarily to + * OrthancPluginCheckVersion(), it is up to the developer of the + * plugin to make sure that all the Orthanc SDK services called by + * the plugin are actually implemented in the given version of + * Orthanc. * * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). * @return 1 if and only if the versions are compatible. If the * result is 0, the initialization of the plugin should fail. + * @see OrthancPluginCheckVersion * @ingroup Callbacks **/ - ORTHANC_PLUGIN_INLINE int OrthancPluginCheckVersion( - OrthancPluginContext* context) + ORTHANC_PLUGIN_INLINE int OrthancPluginCheckVersionAdvanced( + OrthancPluginContext* context, + int expectedMajor, + int expectedMinor, + int expectedRevision) { int major, minor, revision; @@ -1332,31 +1338,31 @@ /* Check the major number of the version */ - if (major > ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER) + if (major > expectedMajor) { return 1; } - if (major < ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER) + if (major < expectedMajor) { return 0; } /* Check the minor number of the version */ - if (minor > ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER) + if (minor > expectedMinor) { return 1; } - if (minor < ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER) + if (minor < expectedMinor) { return 0; } /* Check the revision number of the version */ - if (revision >= ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER) + if (revision >= expectedRevision) { return 1; } @@ -1368,6 +1374,33 @@ /** + * @brief Check the compatibility of the plugin wrt. the version of its hosting Orthanc. + * + * This function checks whether the version of the Orthanc server + * running this plugin, is above the version of the current Orthanc + * SDK header. This guarantees that the plugin is compatible with + * the hosting Orthanc (i.e. it will not call unavailable services). + * The result of this function should always be checked in the + * OrthancPluginInitialize() entry point of the plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return 1 if and only if the versions are compatible. If the + * result is 0, the initialization of the plugin should fail. + * @see OrthancPluginCheckVersionAdvanced + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE int OrthancPluginCheckVersion( + OrthancPluginContext* context) + { + return OrthancPluginCheckVersionAdvanced( + context, + ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, + ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, + ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); + } + + + /** * @brief Free a memory buffer. * * Free a memory buffer that was allocated by the core system of Orthanc.