Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPlugins.cpp @ 1425:97268448bdfc
refactoring of samples
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 26 Jun 2015 16:23:27 +0200 |
parents | fe384a9d3b51 |
children | ad94a3583b07 |
comparison
equal
deleted
inserted
replaced
1424:fe384a9d3b51 | 1425:97268448bdfc |
---|---|
661 translatedOutput->SetContentType("image/png"); | 661 translatedOutput->SetContentType("image/png"); |
662 translatedOutput->SendBody(png); | 662 translatedOutput->SendBody(png); |
663 } | 663 } |
664 | 664 |
665 | 665 |
666 void OrthancPlugins::CheckContextAvailable() | |
667 { | |
668 if (!pimpl_->context_) | |
669 { | |
670 LOG(ERROR) << "Plugin trying to call the database during its initialization"; | |
671 throw OrthancException(ErrorCode_Plugin); | |
672 } | |
673 } | |
674 | |
675 | |
666 void OrthancPlugins::GetDicomForInstance(const void* parameters) | 676 void OrthancPlugins::GetDicomForInstance(const void* parameters) |
667 { | 677 { |
668 assert(pimpl_->context_ != NULL); | 678 CheckContextAvailable(); |
669 | 679 |
670 const _OrthancPluginGetDicomForInstance& p = | 680 const _OrthancPluginGetDicomForInstance& p = |
671 *reinterpret_cast<const _OrthancPluginGetDicomForInstance*>(parameters); | 681 *reinterpret_cast<const _OrthancPluginGetDicomForInstance*>(parameters); |
672 | 682 |
673 std::string dicom; | 683 std::string dicom; |
852 | 862 |
853 default: | 863 default: |
854 throw OrthancException(ErrorCode_InternalError); | 864 throw OrthancException(ErrorCode_InternalError); |
855 } | 865 } |
856 | 866 |
857 assert(pimpl_->context_ != NULL); | 867 CheckContextAvailable(); |
858 | 868 |
859 std::list<std::string> result; | 869 std::list<std::string> result; |
860 pimpl_->context_->GetIndex().LookupIdentifier(result, tag, p.argument, level); | 870 pimpl_->context_->GetIndex().LookupIdentifier(result, tag, p.argument, level); |
861 | 871 |
862 if (result.size() == 1) | 872 if (result.size() == 1) |
1142 { | 1152 { |
1143 return false; | 1153 return false; |
1144 } | 1154 } |
1145 else | 1155 else |
1146 { | 1156 { |
1147 assert(pimpl_->context_ != NULL); | 1157 CheckContextAvailable(); |
1148 pimpl_->context_->GetIndex().SetGlobalProperty(static_cast<GlobalProperty>(p.property), p.value); | 1158 pimpl_->context_->GetIndex().SetGlobalProperty(static_cast<GlobalProperty>(p.property), p.value); |
1149 return true; | 1159 return true; |
1150 } | 1160 } |
1151 } | 1161 } |
1152 | 1162 |
1153 case _OrthancPluginService_GetGlobalProperty: | 1163 case _OrthancPluginService_GetGlobalProperty: |
1154 { | 1164 { |
1155 assert(pimpl_->context_ != NULL); | 1165 CheckContextAvailable(); |
1156 | 1166 |
1157 const _OrthancPluginGlobalProperty& p = | 1167 const _OrthancPluginGlobalProperty& p = |
1158 *reinterpret_cast<const _OrthancPluginGlobalProperty*>(parameters); | 1168 *reinterpret_cast<const _OrthancPluginGlobalProperty*>(parameters); |
1159 std::string result = pimpl_->context_->GetIndex().GetGlobalProperty(static_cast<GlobalProperty>(p.property), p.value); | 1169 std::string result = pimpl_->context_->GetIndex().GetGlobalProperty(static_cast<GlobalProperty>(p.property), p.value); |
1160 *(p.result) = CopyString(result); | 1170 *(p.result) = CopyString(result); |