Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPlugins.cpp @ 1825:f0f8a94c0858
only one modality worklist handler at once
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 25 Nov 2015 14:24:26 +0100 |
parents | 580951a33583 |
children | ac5b0b4e2434 |
comparison
equal
deleted
inserted
replaced
1824:b530c3dfe2a6 | 1825:f0f8a94c0858 |
---|---|
276 | 276 |
277 typedef std::pair<std::string, _OrthancPluginProperty> Property; | 277 typedef std::pair<std::string, _OrthancPluginProperty> Property; |
278 typedef std::list<RestCallback*> RestCallbacks; | 278 typedef std::list<RestCallback*> RestCallbacks; |
279 typedef std::list<OrthancPluginOnStoredInstanceCallback> OnStoredCallbacks; | 279 typedef std::list<OrthancPluginOnStoredInstanceCallback> OnStoredCallbacks; |
280 typedef std::list<OrthancPluginOnChangeCallback> OnChangeCallbacks; | 280 typedef std::list<OrthancPluginOnChangeCallback> OnChangeCallbacks; |
281 typedef std::list<OrthancPluginWorklistCallback> WorklistCallbacks; | |
282 typedef std::map<Property, std::string> Properties; | 281 typedef std::map<Property, std::string> Properties; |
283 | 282 |
284 PluginsManager manager_; | 283 PluginsManager manager_; |
285 ServerContext* context_; | 284 ServerContext* context_; |
286 RestCallbacks restCallbacks_; | 285 RestCallbacks restCallbacks_; |
287 OnStoredCallbacks onStoredCallbacks_; | 286 OnStoredCallbacks onStoredCallbacks_; |
288 OnChangeCallbacks onChangeCallbacks_; | 287 OnChangeCallbacks onChangeCallbacks_; |
289 WorklistCallbacks worklistCallbacks_; | 288 OrthancPluginWorklistCallback worklistCallback_; |
290 std::auto_ptr<StorageAreaFactory> storageArea_; | 289 std::auto_ptr<StorageAreaFactory> storageArea_; |
291 boost::recursive_mutex restCallbackMutex_; | 290 boost::recursive_mutex restCallbackMutex_; |
292 boost::recursive_mutex storedCallbackMutex_; | 291 boost::recursive_mutex storedCallbackMutex_; |
293 boost::recursive_mutex changeCallbackMutex_; | 292 boost::recursive_mutex changeCallbackMutex_; |
294 boost::recursive_mutex worklistCallbackMutex_; | 293 boost::mutex worklistCallbackMutex_; |
295 boost::recursive_mutex invokeServiceMutex_; | 294 boost::recursive_mutex invokeServiceMutex_; |
296 Properties properties_; | 295 Properties properties_; |
297 int argc_; | 296 int argc_; |
298 char** argv_; | 297 char** argv_; |
299 std::auto_ptr<OrthancPluginDatabase> database_; | 298 std::auto_ptr<OrthancPluginDatabase> database_; |
300 PluginsErrorDictionary dictionary_; | 299 PluginsErrorDictionary dictionary_; |
301 | 300 |
302 PImpl() : | 301 PImpl() : |
303 context_(NULL), | 302 context_(NULL), |
303 worklistCallback_(NULL), | |
304 argc_(1), | 304 argc_(1), |
305 argv_(NULL) | 305 argv_(NULL) |
306 { | 306 { |
307 } | 307 } |
308 }; | 308 }; |
337 bool caseSensitivePN = Configuration::GetGlobalBoolParameter("CaseSensitivePN", false); | 337 bool caseSensitivePN = Configuration::GetGlobalBoolParameter("CaseSensitivePN", false); |
338 matcher_.reset(new HierarchicalMatcher(query, caseSensitivePN)); | 338 matcher_.reset(new HierarchicalMatcher(query, caseSensitivePN)); |
339 currentQuery_ = &query; | 339 currentQuery_ = &query; |
340 | 340 |
341 { | 341 { |
342 boost::recursive_mutex::scoped_lock lock(that_.pimpl_->worklistCallbackMutex_); | 342 boost::mutex::scoped_lock lock(that_.pimpl_->worklistCallbackMutex_); |
343 | 343 |
344 for (PImpl::WorklistCallbacks::const_iterator | 344 if (that_.pimpl_->worklistCallback_) |
345 callback = that_.pimpl_->worklistCallbacks_.begin(); | 345 { |
346 callback != that_.pimpl_->worklistCallbacks_.end(); ++callback) | 346 OrthancPluginErrorCode error = that_.pimpl_->worklistCallback_ |
347 { | |
348 OrthancPluginErrorCode error = (*callback) | |
349 (reinterpret_cast<OrthancPluginWorklistAnswers*>(&answers), | 347 (reinterpret_cast<OrthancPluginWorklistAnswers*>(&answers), |
350 reinterpret_cast<const OrthancPluginWorklistQuery*>(this), | 348 reinterpret_cast<const OrthancPluginWorklistQuery*>(this), |
351 remoteAet.c_str(), | 349 remoteAet.c_str(), |
352 calledAet.c_str()); | 350 calledAet.c_str()); |
353 | 351 |
716 void OrthancPlugins::RegisterWorklistCallback(const void* parameters) | 714 void OrthancPlugins::RegisterWorklistCallback(const void* parameters) |
717 { | 715 { |
718 const _OrthancPluginWorklistCallback& p = | 716 const _OrthancPluginWorklistCallback& p = |
719 *reinterpret_cast<const _OrthancPluginWorklistCallback*>(parameters); | 717 *reinterpret_cast<const _OrthancPluginWorklistCallback*>(parameters); |
720 | 718 |
721 LOG(INFO) << "Plugin has registered an modality worklist callback"; | 719 boost::mutex::scoped_lock lock(pimpl_->worklistCallbackMutex_); |
722 pimpl_->worklistCallbacks_.push_back(p.callback); | 720 |
721 if (pimpl_->worklistCallback_ != NULL) | |
722 { | |
723 LOG(ERROR) << "Can only register one plugin to handle modality worklists"; | |
724 throw OrthancException(ErrorCode_Plugin); | |
725 } | |
726 else | |
727 { | |
728 LOG(INFO) << "Plugin has registered an modality worklist callback"; | |
729 pimpl_->worklistCallback_ = p.callback; | |
730 } | |
723 } | 731 } |
724 | 732 |
725 | 733 |
726 | 734 |
727 | 735 |
2135 } | 2143 } |
2136 | 2144 |
2137 | 2145 |
2138 bool OrthancPlugins::HasWorklistHandler() | 2146 bool OrthancPlugins::HasWorklistHandler() |
2139 { | 2147 { |
2140 boost::recursive_mutex::scoped_lock lock(pimpl_->worklistCallbackMutex_); | 2148 boost::mutex::scoped_lock lock(pimpl_->worklistCallbackMutex_); |
2141 return !pimpl_->worklistCallbacks_.empty(); | 2149 return pimpl_->worklistCallback_ != NULL; |
2142 } | 2150 } |
2143 | 2151 |
2144 } | 2152 } |