Mercurial > hg > orthanc
annotate OrthancServer/Sources/StorageCommitmentReports.h @ 5853:4d932683049d get-scu tip
very first implementation of C-Get SCU
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 29 Oct 2024 17:25:49 +0100 |
parents | f7adfb22e20e |
children |
rev | line source |
---|---|
3736
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
3736
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * This program is free software: you can redistribute it and/or |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * modify it under the terms of the GNU General Public License as |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * published by the Free Software Foundation, either version 3 of the |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * License, or (at your option) any later version. |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * This program is distributed in the hope that it will be useful, but |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * General Public License for more details. |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * You should have received a copy of the GNU General Public License |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 **/ |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #pragma once |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
4045 | 26 #include "../../OrthancFramework/Sources/Cache/LeastRecentlyUsedIndex.h" |
3736
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
4304 | 28 #include <boost/thread/mutex.hpp> |
29 | |
3736
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 namespace Orthanc |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 { |
4205 | 32 class StorageCommitmentReports : public boost::noncopyable |
3736
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 { |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 public: |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 class Report : public boost::noncopyable |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 { |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 public: |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 enum Status |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 { |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 Status_Success, |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 Status_Failure, |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 Status_Pending |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 }; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 private: |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 struct Success |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 { |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 std::string sopClassUid_; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 std::string sopInstanceUid_; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 }; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 struct Failure |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 { |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 std::string sopClassUid_; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 std::string sopInstanceUid_; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 StorageCommitmentFailureReason reason_; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 }; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 bool isComplete_; |
3737
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3736
diff
changeset
|
60 std::list<Success> success_; |
3736
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 std::list<Failure> failures_; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 std::string remoteAet_; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 public: |
4205 | 65 explicit Report(const std::string& remoteAet) : |
3736
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 isComplete_(false), |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 remoteAet_(remoteAet) |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 { |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 } |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 const std::string& GetRemoteAet() const |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 { |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 return remoteAet_; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 } |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 void MarkAsComplete(); |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 void AddSuccess(const std::string& sopClassUid, |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 const std::string& sopInstanceUid); |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 void AddFailure(const std::string& sopClassUid, |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 const std::string& sopInstanceUid, |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 StorageCommitmentFailureReason reason); |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 Status GetStatus() const; |
3737
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3736
diff
changeset
|
86 |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3736
diff
changeset
|
87 void Format(Json::Value& json) const; |
3738
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
88 |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
89 void GetSuccessSopInstanceUids(std::vector<std::string>& target) const; |
3736
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 }; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 private: |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 typedef LeastRecentlyUsedIndex<std::string, Report*> Content; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 boost::mutex mutex_; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 Content content_; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 size_t maxSize_; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 public: |
4205 | 100 explicit StorageCommitmentReports(size_t maxSize) : |
3736
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 maxSize_(maxSize) |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 { |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 } |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 ~StorageCommitmentReports(); |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 size_t GetMaxSize() const |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 { |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 return maxSize_; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 } |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 void Store(const std::string& transactionUid, |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 Report* report); // Takes ownership |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 class Accessor : public boost::noncopyable |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 { |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 private: |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 boost::mutex::scoped_lock lock_; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 std::string transactionUid_; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 Report *report_; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 public: |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 Accessor(StorageCommitmentReports& that, |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 const std::string& transactionUid); |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 const std::string& GetTransactionUid() const |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 { |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 return transactionUid_; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 } |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 bool IsValid() const |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 { |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 return report_ != NULL; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 } |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 const Report& GetReport() const; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 }; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 }; |
0540b54324f1
StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 } |