Mercurial > hg > orthanc
comparison Plugins/Samples/Common/OrthancPluginCppWrapper.cpp @ 2213:95d1d758abb7
FindMatcher::IsMatch
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 10 Dec 2016 10:17:44 +0100 |
parents | c02f6ec404d8 |
children | 028214a95194 |
comparison
equal
deleted
inserted
replaced
2212:c02f6ec404d8 | 2213:95d1d758abb7 |
---|---|
834 GetWidth(), GetHeight(), GetPitch(), GetBuffer(), quality); | 834 GetWidth(), GetHeight(), GetPitch(), GetBuffer(), quality); |
835 } | 835 } |
836 | 836 |
837 | 837 |
838 FindMatcher::FindMatcher(OrthancPluginContext* context, | 838 FindMatcher::FindMatcher(OrthancPluginContext* context, |
839 const OrthancPluginWorklistQuery* query) : | 839 const OrthancPluginWorklistQuery* worklist) : |
840 context_(context), | 840 context_(context), |
841 matcher_(NULL), | 841 matcher_(NULL), |
842 query_(query) | 842 worklist_(worklist) |
843 { | 843 { |
844 if (query_ == NULL) | 844 if (worklist_ == NULL) |
845 { | 845 { |
846 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); | 846 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); |
847 } | 847 } |
848 } | 848 } |
849 | 849 |
850 | 850 |
851 FindMatcher::FindMatcher(OrthancPluginContext* context, | 851 FindMatcher::FindMatcher(OrthancPluginContext* context, |
852 const void* query, | 852 const void* query, |
853 uint32_t size) : | 853 uint32_t size) : |
854 context_(context), | 854 context_(context), |
855 query_(NULL) | 855 worklist_(NULL) |
856 { | 856 { |
857 matcher_ = OrthancPluginCreateFindMatcher(context_, query, size); | 857 matcher_ = OrthancPluginCreateFindMatcher(context_, query, size); |
858 if (matcher_ == NULL) | 858 if (matcher_ == NULL) |
859 { | 859 { |
860 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InternalError); | 860 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InternalError); |
862 } | 862 } |
863 | 863 |
864 | 864 |
865 FindMatcher::~FindMatcher() | 865 FindMatcher::~FindMatcher() |
866 { | 866 { |
867 // The "worklist_" field | |
868 | |
867 if (matcher_ != NULL) | 869 if (matcher_ != NULL) |
868 { | 870 { |
869 OrthancPluginFreeFindMatcher(context_, matcher_); | 871 OrthancPluginFreeFindMatcher(context_, matcher_); |
870 } | 872 } |
871 } | 873 } |
874 | |
875 | |
876 | |
877 bool FindMatcher::IsMatch(const void* dicom, | |
878 uint32_t size) const | |
879 { | |
880 int32_t result; | |
881 | |
882 if (matcher_ != NULL) | |
883 { | |
884 result = OrthancPluginFindMatcherIsMatch(context_, matcher_, dicom, size); | |
885 } | |
886 else if (worklist_ != NULL) | |
887 { | |
888 result = OrthancPluginWorklistIsMatch(context_, worklist_, dicom, size); | |
889 } | |
890 else | |
891 { | |
892 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InternalError); | |
893 } | |
894 | |
895 if (result == 0) | |
896 { | |
897 return false; | |
898 } | |
899 else if (result == 1) | |
900 { | |
901 return true; | |
902 } | |
903 else | |
904 { | |
905 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InternalError); | |
906 } | |
907 } | |
908 | |
872 | 909 |
873 | 910 |
874 bool RestApiGet(Json::Value& result, | 911 bool RestApiGet(Json::Value& result, |
875 OrthancPluginContext* context, | 912 OrthancPluginContext* context, |
876 const std::string& uri, | 913 const std::string& uri, |