Mercurial > hg > orthanc
comparison OrthancServer/Plugins/Engine/OrthancPlugins.cpp @ 4204:318c16cfccab
cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 17 Sep 2020 16:18:01 +0200 |
parents | 2d5209153b32 |
children | 3d6f14a05db1 |
comparison
equal
deleted
inserted
replaced
4203:4d42408da117 | 4204:318c16cfccab |
---|---|
367 throw OrthancException(ErrorCode_ParameterOutOfRange); | 367 throw OrthancException(ErrorCode_ParameterOutOfRange); |
368 } | 368 } |
369 } | 369 } |
370 | 370 |
371 public: | 371 public: |
372 DicomWebBinaryFormatter(OrthancPluginDicomWebBinaryCallback callback) : | 372 explicit DicomWebBinaryFormatter(OrthancPluginDicomWebBinaryCallback callback) : |
373 oldCallback_(callback), | 373 oldCallback_(callback), |
374 newCallback_(NULL), | 374 newCallback_(NULL), |
375 newPayload_(NULL) | 375 newPayload_(NULL), |
376 currentMode_(DicomWebJsonVisitor::BinaryMode_Ignore) | |
376 { | 377 { |
377 } | 378 } |
378 | 379 |
379 DicomWebBinaryFormatter(OrthancPluginDicomWebBinaryCallback2 callback, | 380 DicomWebBinaryFormatter(OrthancPluginDicomWebBinaryCallback2 callback, |
380 void* payload) : | 381 void* payload) : |
381 oldCallback_(NULL), | 382 oldCallback_(NULL), |
382 newCallback_(callback), | 383 newCallback_(callback), |
383 newPayload_(payload) | 384 newPayload_(payload), |
385 currentMode_(DicomWebJsonVisitor::BinaryMode_Ignore) | |
384 { | 386 { |
385 } | 387 } |
386 | 388 |
387 virtual DicomWebJsonVisitor::BinaryMode Format(std::string& bulkDataUri, | 389 virtual DicomWebJsonVisitor::BinaryMode Format(std::string& bulkDataUri, |
388 const std::vector<DicomTag>& parentTags, | 390 const std::vector<DicomTag>& parentTags, |
389 const std::vector<size_t>& parentIndexes, | 391 const std::vector<size_t>& parentIndexes, |
390 const DicomTag& tag, | 392 const DicomTag& tag, |
391 ValueRepresentation vr) | 393 ValueRepresentation vr) ORTHANC_OVERRIDE |
392 { | 394 { |
393 if (oldCallback_ == NULL && | 395 if (oldCallback_ == NULL && |
394 newCallback_ == NULL) | 396 newCallback_ == NULL) |
395 { | 397 { |
396 return DicomWebJsonVisitor::BinaryMode_InlineBinary; | 398 return DicomWebJsonVisitor::BinaryMode_InlineBinary; |
444 } | 446 } |
445 } | 447 } |
446 | 448 |
447 void Apply(char** target, | 449 void Apply(char** target, |
448 bool isJson, | 450 bool isJson, |
449 ParsedDicomFile& dicom) | 451 const ParsedDicomFile& dicom) |
450 { | 452 { |
451 DicomWebJsonVisitor visitor; | 453 DicomWebJsonVisitor visitor; |
452 visitor.SetFormatter(*this); | 454 visitor.SetFormatter(*this); |
453 | 455 |
454 dicom.Apply(visitor); | 456 dicom.Apply(visitor); |
504 MultipartState multipartState_; | 506 MultipartState multipartState_; |
505 std::string multipartSubType_; | 507 std::string multipartSubType_; |
506 std::string multipartContentType_; | 508 std::string multipartContentType_; |
507 std::string multipartFirstPart_; | 509 std::string multipartFirstPart_; |
508 std::map<std::string, std::string> multipartFirstHeaders_; | 510 std::map<std::string, std::string> multipartFirstHeaders_; |
509 | 511 |
510 public: | 512 public: |
511 PluginHttpOutput(HttpOutput& output) : | 513 explicit PluginHttpOutput(HttpOutput& output) : |
512 output_(output), | 514 output_(output), |
513 logDetails_(false), | 515 logDetails_(false), |
514 multipartState_(MultipartState_None) | 516 multipartState_(MultipartState_None) |
515 { | 517 { |
516 } | 518 } |
726 private: | 728 private: |
727 _OrthancPluginChunkedRestCallback parameters_; | 729 _OrthancPluginChunkedRestCallback parameters_; |
728 boost::regex regex_; | 730 boost::regex regex_; |
729 | 731 |
730 public: | 732 public: |
731 ChunkedRestCallback(_OrthancPluginChunkedRestCallback parameters) : | 733 explicit ChunkedRestCallback(_OrthancPluginChunkedRestCallback parameters) : |
732 parameters_(parameters), | 734 parameters_(parameters), |
733 regex_(parameters.pathRegularExpression) | 735 regex_(parameters.pathRegularExpression) |
734 { | 736 { |
735 } | 737 } |
736 | 738 |
773 assert(handler_ != NULL); | 775 assert(handler_ != NULL); |
774 parameters_.destructor(handler_); | 776 parameters_.destructor(handler_); |
775 handler_ = NULL; | 777 handler_ = NULL; |
776 } | 778 } |
777 | 779 |
778 virtual StorageCommitmentFailureReason Lookup(const std::string& sopClassUid, | 780 virtual StorageCommitmentFailureReason Lookup( |
779 const std::string& sopInstanceUid) | 781 const std::string& sopClassUid, |
782 const std::string& sopInstanceUid) ORTHANC_OVERRIDE | |
780 { | 783 { |
781 assert(handler_ != NULL); | 784 assert(handler_ != NULL); |
782 OrthancPluginStorageCommitmentFailureReason reason = | 785 OrthancPluginStorageCommitmentFailureReason reason = |
783 OrthancPluginStorageCommitmentFailureReason_Success; | 786 OrthancPluginStorageCommitmentFailureReason_Success; |
784 OrthancPluginErrorCode error = parameters_.lookup( | 787 OrthancPluginErrorCode error = parameters_.lookup( |
795 }; | 798 }; |
796 | 799 |
797 _OrthancPluginRegisterStorageCommitmentScpCallback parameters_; | 800 _OrthancPluginRegisterStorageCommitmentScpCallback parameters_; |
798 | 801 |
799 public: | 802 public: |
800 StorageCommitmentScp(_OrthancPluginRegisterStorageCommitmentScpCallback parameters) : | 803 explicit StorageCommitmentScp(_OrthancPluginRegisterStorageCommitmentScpCallback parameters) : |
801 parameters_(parameters) | 804 parameters_(parameters) |
802 { | 805 { |
803 } | 806 } |
804 | 807 |
805 virtual ILookupHandler* CreateStorageCommitment( | 808 virtual ILookupHandler* CreateStorageCommitment( |
855 private: | 858 private: |
856 boost::mutex::scoped_lock lock_; | 859 boost::mutex::scoped_lock lock_; |
857 ServerContext* context_; | 860 ServerContext* context_; |
858 | 861 |
859 public: | 862 public: |
860 ServerContextLock(PImpl& that) : | 863 explicit ServerContextLock(PImpl& that) : |
861 lock_(that.contextMutex_), | 864 lock_(that.contextMutex_), |
862 context_(that.context_) | 865 context_(that.context_) |
863 { | 866 { |
864 if (context_ == NULL) | 867 if (context_ == NULL) |
865 { | 868 { |
960 filtered_.reset(); | 963 filtered_.reset(); |
961 currentQuery_ = NULL; | 964 currentQuery_ = NULL; |
962 } | 965 } |
963 | 966 |
964 public: | 967 public: |
965 WorklistHandler(OrthancPlugins& that) : that_(that) | 968 explicit WorklistHandler(OrthancPlugins& that) : that_(that) |
966 { | 969 { |
967 Reset(); | 970 Reset(); |
968 } | 971 } |
969 | 972 |
970 virtual void Handle(DicomFindAnswers& answers, | 973 virtual void Handle(DicomFindAnswers& answers, |
972 const std::string& remoteIp, | 975 const std::string& remoteIp, |
973 const std::string& remoteAet, | 976 const std::string& remoteAet, |
974 const std::string& calledAet, | 977 const std::string& calledAet, |
975 ModalityManufacturer manufacturer) | 978 ModalityManufacturer manufacturer) |
976 { | 979 { |
977 static const char* LUA_CALLBACK = "IncomingWorklistRequestFilter"; | 980 { |
978 | 981 static const char* LUA_CALLBACK = "IncomingWorklistRequestFilter"; |
979 { | 982 |
980 PImpl::ServerContextLock lock(*that_.pimpl_); | 983 PImpl::ServerContextLock lock(*that_.pimpl_); |
981 LuaScripting::Lock lua(lock.GetContext().GetLuaScripting()); | 984 LuaScripting::Lock lua(lock.GetContext().GetLuaScripting()); |
982 | 985 |
983 if (!lua.GetLua().IsExistingFunction(LUA_CALLBACK)) | 986 if (!lua.GetLua().IsExistingFunction(LUA_CALLBACK)) |
984 { | 987 { |
1080 { | 1083 { |
1081 currentQuery_.reset(NULL); | 1084 currentQuery_.reset(NULL); |
1082 } | 1085 } |
1083 | 1086 |
1084 public: | 1087 public: |
1085 FindHandler(OrthancPlugins& that) : that_(that) | 1088 explicit FindHandler(OrthancPlugins& that) : that_(that) |
1086 { | 1089 { |
1087 Reset(); | 1090 Reset(); |
1088 } | 1091 } |
1089 | 1092 |
1090 virtual void Handle(DicomFindAnswers& answers, | 1093 virtual void Handle(DicomFindAnswers& answers, |
1262 } | 1265 } |
1263 | 1266 |
1264 | 1267 |
1265 | 1268 |
1266 public: | 1269 public: |
1267 MoveHandler(OrthancPlugins& that) | 1270 explicit MoveHandler(OrthancPlugins& that) |
1268 { | 1271 { |
1269 boost::recursive_mutex::scoped_lock lock(that.pimpl_->invokeServiceMutex_); | 1272 boost::recursive_mutex::scoped_lock lock(that.pimpl_->invokeServiceMutex_); |
1270 params_ = that.pimpl_->moveCallbacks_; | 1273 params_ = that.pimpl_->moveCallbacks_; |
1271 | 1274 |
1272 if (params_.callback == NULL || | 1275 if (params_.callback == NULL || |
1336 params_(params), | 1339 params_(params), |
1337 errorDictionary_(errorDictionary) | 1340 errorDictionary_(errorDictionary) |
1338 { | 1341 { |
1339 } | 1342 } |
1340 | 1343 |
1341 virtual bool ReadNextChunk(std::string& chunk) | 1344 virtual bool ReadNextChunk(std::string& chunk) ORTHANC_OVERRIDE |
1342 { | 1345 { |
1343 if (params_.requestIsDone(params_.request)) | 1346 if (params_.requestIsDone(params_.request)) |
1344 { | 1347 { |
1345 return false; | 1348 return false; |
1346 } | 1349 } |
1385 errorDictionary_(errorDictionary) | 1388 errorDictionary_(errorDictionary) |
1386 { | 1389 { |
1387 } | 1390 } |
1388 | 1391 |
1389 virtual void AddHeader(const std::string& key, | 1392 virtual void AddHeader(const std::string& key, |
1390 const std::string& value) | 1393 const std::string& value) ORTHANC_OVERRIDE |
1391 { | 1394 { |
1392 OrthancPluginErrorCode error = params_.answerAddHeader(params_.answer, key.c_str(), value.c_str()); | 1395 OrthancPluginErrorCode error = params_.answerAddHeader(params_.answer, key.c_str(), value.c_str()); |
1393 | 1396 |
1394 if (error != OrthancPluginErrorCode_Success) | 1397 if (error != OrthancPluginErrorCode_Success) |
1395 { | 1398 { |
1397 throw OrthancException(static_cast<ErrorCode>(error)); | 1400 throw OrthancException(static_cast<ErrorCode>(error)); |
1398 } | 1401 } |
1399 } | 1402 } |
1400 | 1403 |
1401 virtual void AddChunk(const void* data, | 1404 virtual void AddChunk(const void* data, |
1402 size_t size) | 1405 size_t size) ORTHANC_OVERRIDE |
1403 { | 1406 { |
1404 OrthancPluginErrorCode error = params_.answerAddChunk(params_.answer, data, size); | 1407 OrthancPluginErrorCode error = params_.answerAddChunk(params_.answer, data, size); |
1405 | 1408 |
1406 if (error != OrthancPluginErrorCode_Success) | 1409 if (error != OrthancPluginErrorCode_Success) |
1407 { | 1410 { |
1531 std::string flatUri_; | 1534 std::string flatUri_; |
1532 std::vector<std::string> groups_; | 1535 std::vector<std::string> groups_; |
1533 std::vector<const char*> cgroups_; | 1536 std::vector<const char*> cgroups_; |
1534 | 1537 |
1535 public: | 1538 public: |
1536 RestCallbackMatcher(const UriComponents& uri) : | 1539 explicit RestCallbackMatcher(const UriComponents& uri) : |
1537 flatUri_(Toolbox::FlattenUri(uri)) | 1540 flatUri_(Toolbox::FlattenUri(uri)) |
1538 { | 1541 { |
1539 } | 1542 } |
1540 | 1543 |
1541 bool IsMatch(const boost::regex& re) | 1544 bool IsMatch(const boost::regex& re) |
1844 { | 1847 { |
1845 private: | 1848 private: |
1846 const DicomInstanceToStore& instance_; | 1849 const DicomInstanceToStore& instance_; |
1847 | 1850 |
1848 public: | 1851 public: |
1849 DicomInstanceFromCallback(const DicomInstanceToStore& instance) : | 1852 explicit DicomInstanceFromCallback(const DicomInstanceToStore& instance) : |
1850 instance_(instance) | 1853 instance_(instance) |
1851 { | 1854 { |
1852 } | 1855 } |
1853 | 1856 |
1854 virtual bool CanBeFreed() const ORTHANC_OVERRIDE | 1857 virtual bool CanBeFreed() const ORTHANC_OVERRIDE |
1895 private: | 1898 private: |
1896 std::unique_ptr<ParsedDicomFile> parsed_; | 1899 std::unique_ptr<ParsedDicomFile> parsed_; |
1897 DicomInstanceToStore instance_; | 1900 DicomInstanceToStore instance_; |
1898 | 1901 |
1899 public: | 1902 public: |
1900 DicomInstanceFromTranscoded(IDicomTranscoder::DicomImage& transcoded) : | 1903 explicit DicomInstanceFromTranscoded(IDicomTranscoder::DicomImage& transcoded) : |
1901 parsed_(transcoded.ReleaseAsParsedDicomFile()) | 1904 parsed_(transcoded.ReleaseAsParsedDicomFile()) |
1902 { | 1905 { |
1903 instance_.SetParsedDicomFile(*parsed_); | 1906 instance_.SetParsedDicomFile(*parsed_); |
1904 instance_.SetOrigin(DicomInstanceOrigin::FromPlugins()); | 1907 instance_.SetOrigin(DicomInstanceOrigin::FromPlugins()); |
1905 } | 1908 } |
3325 | 3328 |
3326 void OrthancPlugins::DrawText(const void* parameters) | 3329 void OrthancPlugins::DrawText(const void* parameters) |
3327 { | 3330 { |
3328 const _OrthancPluginDrawText& p = *reinterpret_cast<const _OrthancPluginDrawText*>(parameters); | 3331 const _OrthancPluginDrawText& p = *reinterpret_cast<const _OrthancPluginDrawText*>(parameters); |
3329 | 3332 |
3330 ImageAccessor& target = *reinterpret_cast<ImageAccessor*>(p.image); | |
3331 | |
3332 { | 3333 { |
3333 OrthancConfiguration::ReaderLock lock; | 3334 OrthancConfiguration::ReaderLock lock; |
3334 const Font& font = lock.GetConfiguration().GetFontRegistry().GetFont(p.fontIndex); | 3335 const Font& font = lock.GetConfiguration().GetFontRegistry().GetFont(p.fontIndex); |
3336 | |
3337 ImageAccessor& target = *reinterpret_cast<ImageAccessor*>(p.image); | |
3335 font.Draw(target, p.utf8Text, p.x, p.y, p.r, p.g, p.b); | 3338 font.Draw(target, p.utf8Text, p.x, p.y, p.r, p.g, p.b); |
3336 } | 3339 } |
3337 } | 3340 } |
3338 | 3341 |
3339 | 3342 |
5035 assert(reader_ != NULL); | 5038 assert(reader_ != NULL); |
5036 parameters_.finalize(reader_); | 5039 parameters_.finalize(reader_); |
5037 } | 5040 } |
5038 | 5041 |
5039 virtual void AddBodyChunk(const void* data, | 5042 virtual void AddBodyChunk(const void* data, |
5040 size_t size) | 5043 size_t size) ORTHANC_OVERRIDE |
5041 { | 5044 { |
5042 if (static_cast<uint32_t>(size) != size) | 5045 if (static_cast<uint32_t>(size) != size) |
5043 { | 5046 { |
5044 throw OrthancException(ErrorCode_NotEnoughMemory, ERROR_MESSAGE_64BIT); | 5047 throw OrthancException(ErrorCode_NotEnoughMemory, ERROR_MESSAGE_64BIT); |
5045 } | 5048 } |
5046 | 5049 |
5047 assert(reader_ != NULL); | 5050 assert(reader_ != NULL); |
5048 parameters_.addChunk(reader_, data, size); | 5051 parameters_.addChunk(reader_, data, size); |
5049 } | 5052 } |
5050 | 5053 |
5051 virtual void Execute(HttpOutput& output) | 5054 virtual void Execute(HttpOutput& output) ORTHANC_OVERRIDE |
5052 { | 5055 { |
5053 assert(reader_ != NULL); | 5056 assert(reader_ != NULL); |
5054 | 5057 |
5055 PImpl::PluginHttpOutput pluginOutput(output); | 5058 PImpl::PluginHttpOutput pluginOutput(output); |
5056 | 5059 |