Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
3178:6d558598d713 | 3179:fca730c267d7 |
---|---|
36 #include "OrthancPluginException.h" | 36 #include "OrthancPluginException.h" |
37 | 37 |
38 #include <orthanc/OrthancCPlugin.h> | 38 #include <orthanc/OrthancCPlugin.h> |
39 #include <boost/noncopyable.hpp> | 39 #include <boost/noncopyable.hpp> |
40 #include <boost/lexical_cast.hpp> | 40 #include <boost/lexical_cast.hpp> |
41 #include <boost/date_time/posix_time/posix_time.hpp> | |
41 #include <json/value.h> | 42 #include <json/value.h> |
42 #include <vector> | 43 #include <vector> |
43 #include <list> | 44 #include <list> |
44 #include <set> | 45 #include <set> |
45 #include <map> | 46 #include <map> |
47 | 48 |
48 | 49 |
49 #if !defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) | 50 #if !defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) |
50 #define ORTHANC_PLUGINS_VERSION_IS_ABOVE(major, minor, revision) \ | 51 #define ORTHANC_PLUGINS_VERSION_IS_ABOVE(major, minor, revision) \ |
51 (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER > major || \ | 52 (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER > major || \ |
52 (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER == major && \ | 53 (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER == major && \ |
53 (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER > minor || \ | 54 (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER > minor || \ |
54 (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER == minor && \ | 55 (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER == minor && \ |
55 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER >= revision)))) | 56 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER >= revision)))) |
56 #endif | 57 #endif |
57 | 58 |
58 | 59 |
59 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 2, 0) | 60 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 2, 0) |
60 // The "OrthancPluginFindMatcher()" primitive was introduced in Orthanc 1.2.0 | 61 // The "OrthancPluginFindMatcher()" primitive was introduced in Orthanc 1.2.0 |
74 | 75 |
75 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 0) | 76 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 0) |
76 # define HAS_ORTHANC_PLUGIN_EXCEPTION_DETAILS 1 | 77 # define HAS_ORTHANC_PLUGIN_EXCEPTION_DETAILS 1 |
77 #else | 78 #else |
78 # define HAS_ORTHANC_PLUGIN_EXCEPTION_DETAILS 0 | 79 # define HAS_ORTHANC_PLUGIN_EXCEPTION_DETAILS 0 |
80 #endif | |
81 | |
82 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4) | |
83 # define HAS_ORTHANC_PLUGIN_METRICS 1 | |
84 #else | |
85 # define HAS_ORTHANC_PLUGIN_METRICS 0 | |
79 #endif | 86 #endif |
80 | 87 |
81 | 88 |
82 | 89 |
83 namespace OrthancPlugins | 90 namespace OrthancPlugins |
738 | 745 |
739 static std::string Submit(OrthancJob* job /* takes ownership */, | 746 static std::string Submit(OrthancJob* job /* takes ownership */, |
740 int priority); | 747 int priority); |
741 }; | 748 }; |
742 #endif | 749 #endif |
750 | |
751 | |
752 #if HAS_ORTHANC_PLUGIN_METRICS == 1 | |
753 inline void SetMetricsValue(char* name, | |
754 float value) | |
755 { | |
756 OrthancPluginSetMetricsValue(GetGlobalContext(), name, | |
757 value, OrthancPluginMetricsType_Default); | |
758 } | |
759 | |
760 class MetricsTimer : public boost::noncopyable | |
761 { | |
762 private: | |
763 std::string name_; | |
764 boost::posix_time::ptime start_; | |
765 | |
766 public: | |
767 MetricsTimer(const char* name); | |
768 | |
769 ~MetricsTimer(); | |
770 }; | |
771 #endif | |
743 } | 772 } |