Mercurial > hg > orthanc
diff 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 |
line wrap: on
line diff
--- a/Plugins/Engine/OrthancPlugins.cpp Fri Jun 26 15:32:45 2015 +0200 +++ b/Plugins/Engine/OrthancPlugins.cpp Fri Jun 26 16:23:27 2015 +0200 @@ -663,9 +663,19 @@ } + void OrthancPlugins::CheckContextAvailable() + { + if (!pimpl_->context_) + { + LOG(ERROR) << "Plugin trying to call the database during its initialization"; + throw OrthancException(ErrorCode_Plugin); + } + } + + void OrthancPlugins::GetDicomForInstance(const void* parameters) { - assert(pimpl_->context_ != NULL); + CheckContextAvailable(); const _OrthancPluginGetDicomForInstance& p = *reinterpret_cast<const _OrthancPluginGetDicomForInstance*>(parameters); @@ -854,7 +864,7 @@ throw OrthancException(ErrorCode_InternalError); } - assert(pimpl_->context_ != NULL); + CheckContextAvailable(); std::list<std::string> result; pimpl_->context_->GetIndex().LookupIdentifier(result, tag, p.argument, level); @@ -1144,7 +1154,7 @@ } else { - assert(pimpl_->context_ != NULL); + CheckContextAvailable(); pimpl_->context_->GetIndex().SetGlobalProperty(static_cast<GlobalProperty>(p.property), p.value); return true; } @@ -1152,7 +1162,7 @@ case _OrthancPluginService_GetGlobalProperty: { - assert(pimpl_->context_ != NULL); + CheckContextAvailable(); const _OrthancPluginGlobalProperty& p = *reinterpret_cast<const _OrthancPluginGlobalProperty*>(parameters);