comparison OrthancServer/Sources/ServerIndex.cpp @ 4205:d962a2996637

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 17 Sep 2020 17:58:19 +0200
parents 0ddc5297a8ab
children 61a2bedbae80
comparison
equal deleted inserted replaced
4204:318c16cfccab 4205:d962a2996637
84 private: 84 private:
85 std::string uuid_; 85 std::string uuid_;
86 FileContentType type_; 86 FileContentType type_;
87 87
88 public: 88 public:
89 FileToRemove(const FileInfo& info) : uuid_(info.GetUuid()), 89 explicit FileToRemove(const FileInfo& info) :
90 type_(info.GetContentType()) 90 uuid_(info.GetUuid()),
91 type_(info.GetContentType())
91 { 92 {
92 } 93 }
93 94
94 const std::string& GetUuid() const 95 const std::string& GetUuid() const
95 { 96 {
118 pendingFilesToRemove_.clear(); 119 pendingFilesToRemove_.clear();
119 pendingChanges_.clear(); 120 pendingChanges_.clear();
120 } 121 }
121 122
122 public: 123 public:
123 Listener(ServerContext& context) : context_(context), 124 explicit Listener(ServerContext& context) :
124 insideTransaction_(false) 125 context_(context),
126 insideTransaction_(false)
125 { 127 {
126 Reset(); 128 Reset();
127 assert(ResourceType_Patient < ResourceType_Study && 129 assert(ResourceType_Patient < ResourceType_Study &&
128 ResourceType_Study < ResourceType_Series && 130 ResourceType_Study < ResourceType_Series &&
129 ResourceType_Series < ResourceType_Instance); 131 ResourceType_Series < ResourceType_Instance);
240 { 242 {
241 private: 243 private:
242 ServerIndex& index_; 244 ServerIndex& index_;
243 std::unique_ptr<IDatabaseWrapper::ITransaction> transaction_; 245 std::unique_ptr<IDatabaseWrapper::ITransaction> transaction_;
244 bool isCommitted_; 246 bool isCommitted_;
245 247
246 public: 248 public:
247 Transaction(ServerIndex& index) : 249 explicit Transaction(ServerIndex& index) :
248 index_(index), 250 index_(index),
249 isCommitted_(false) 251 isCommitted_(false)
250 { 252 {
251 transaction_.reset(index_.db_.StartTransaction()); 253 transaction_.reset(index_.db_.StartTransaction());
252 transaction_->Begin(); 254 transaction_->Begin();
300 } 302 }
301 303
302 UnstableResourcePayload(Orthanc::ResourceType type, 304 UnstableResourcePayload(Orthanc::ResourceType type,
303 const std::string& publicId) : 305 const std::string& publicId) :
304 type_(type), 306 type_(type),
305 publicId_(publicId) 307 publicId_(publicId),
306 { 308 time_(boost::posix_time::second_clock::local_time())
307 time_ = boost::posix_time::second_clock::local_time(); 309 {
308 } 310 }
309 311
310 unsigned int GetAge() const 312 unsigned int GetAge() const
311 { 313 {
312 return (boost::posix_time::second_clock::local_time() - time_).total_seconds(); 314 return (boost::posix_time::second_clock::local_time() - time_).total_seconds();
449 451
450 db_.DeleteResource(id); 452 db_.DeleteResource(id);
451 453
452 if (listener_->HasRemainingLevel()) 454 if (listener_->HasRemainingLevel())
453 { 455 {
454 ResourceType type = listener_->GetRemainingType(); 456 ResourceType remainingType = listener_->GetRemainingType();
455 const std::string& uuid = listener_->GetRemainingPublicId(); 457 const std::string& remainingUuid = listener_->GetRemainingPublicId();
456 458
457 target["RemainingAncestor"] = Json::Value(Json::objectValue); 459 target["RemainingAncestor"] = Json::Value(Json::objectValue);
458 target["RemainingAncestor"]["Path"] = GetBasePath(type, uuid); 460 target["RemainingAncestor"]["Path"] = GetBasePath(remainingType, remainingUuid);
459 target["RemainingAncestor"]["Type"] = EnumerationToString(type); 461 target["RemainingAncestor"]["Type"] = EnumerationToString(remainingType);
460 target["RemainingAncestor"]["ID"] = uuid; 462 target["RemainingAncestor"]["ID"] = remainingUuid;
461 } 463 }
462 else 464 else
463 { 465 {
464 target["RemainingAncestor"] = Json::nullValue; 466 target["RemainingAncestor"] = Json::nullValue;
465 } 467 }
642 { 644 {
643 std::string oldValue; 645 std::string oldValue;
644 646
645 if (db_.LookupGlobalProperty(oldValue, property)) 647 if (db_.LookupGlobalProperty(oldValue, property))
646 { 648 {
647 uint64_t oldNumber;
648
649 try 649 try
650 { 650 {
651 oldNumber = boost::lexical_cast<uint64_t>(oldValue); 651 uint64_t oldNumber = boost::lexical_cast<uint64_t>(oldValue);
652 db_.SetGlobalProperty(property, boost::lexical_cast<std::string>(oldNumber + 1)); 652 db_.SetGlobalProperty(property, boost::lexical_cast<std::string>(oldNumber + 1));
653 return oldNumber + 1; 653 return oldNumber + 1;
654 } 654 }
655 catch (boost::bad_lexical_cast&) 655 catch (boost::bad_lexical_cast&)
656 { 656 {
2463 target = db_.GetPublicId(id); 2463 target = db_.GetPublicId(id);
2464 return true; 2464 return true;
2465 } 2465 }
2466 2466
2467 2467
2468 void ServerIndex::ReconstructInstance(ParsedDicomFile& dicom) 2468 void ServerIndex::ReconstructInstance(const ParsedDicomFile& dicom)
2469 { 2469 {
2470 DicomMap summary; 2470 DicomMap summary;
2471 OrthancConfiguration::DefaultExtractDicomSummary(summary, dicom); 2471 OrthancConfiguration::DefaultExtractDicomSummary(summary, dicom);
2472 2472
2473 DicomInstanceHasher hasher(summary); 2473 DicomInstanceHasher hasher(summary);