diff Plugins/Samples/Common/OrthancPluginCppWrapper.h @ 3179:fca730c267d7

New primitives to set and refresh metrics
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 30 Jan 2019 17:12:15 +0100
parents 4e43e67f8ecf
children 872efde28e58
line wrap: on
line diff
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Wed Jan 30 12:41:20 2019 +0100
+++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Wed Jan 30 17:12:15 2019 +0100
@@ -38,6 +38,7 @@
 #include <orthanc/OrthancCPlugin.h>
 #include <boost/noncopyable.hpp>
 #include <boost/lexical_cast.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
 #include <json/value.h>
 #include <vector>
 #include <list>
@@ -49,10 +50,10 @@
 #if !defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)
 #define ORTHANC_PLUGINS_VERSION_IS_ABOVE(major, minor, revision)        \
   (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER > major ||                      \
-  (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER == major &&                    \
-  (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER > minor ||                    \
-  (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER == minor &&                  \
-  ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER >= revision))))
+   (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER == major &&                    \
+    (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER > minor ||                    \
+     (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER == minor &&                  \
+      ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER >= revision))))
 #endif
 
 
@@ -78,6 +79,12 @@
 #  define HAS_ORTHANC_PLUGIN_EXCEPTION_DETAILS  0
 #endif
 
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4)
+#  define HAS_ORTHANC_PLUGIN_METRICS  1
+#else
+#  define HAS_ORTHANC_PLUGIN_METRICS  0
+#endif
+
 
 
 namespace OrthancPlugins
@@ -740,4 +747,26 @@
                               int priority);
   };
 #endif
+
+
+#if HAS_ORTHANC_PLUGIN_METRICS == 1
+  inline void SetMetricsValue(char* name,
+                              float value)
+  {
+    OrthancPluginSetMetricsValue(GetGlobalContext(), name,
+                                 value, OrthancPluginMetricsType_Default);
+  }
+
+  class MetricsTimer : public boost::noncopyable
+  {
+  private:
+    std::string               name_;
+    boost::posix_time::ptime  start_;
+
+  public:
+    MetricsTimer(const char* name);
+
+    ~MetricsTimer();
+  };
+#endif
 }