Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Loaders/LoaderStateMachine.cpp @ 1925:a7a77488ddb1
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Mar 2022 14:21:22 +0100 |
parents | 7053b8a0aaec |
children | 07964689cb0b |
rev | line source |
---|---|
815 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
815 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
815 | 10 * as published by the Free Software Foundation, either version 3 of |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
16 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
17 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
815 | 21 **/ |
22 | |
23 | |
24 #include "LoaderStateMachine.h" | |
25 | |
1339
556b4bc19118
The loaders have been adapter to the nobroker architecture
Benjamin Golinvaux <bgo@osimis.io>
parents:
1337
diff
changeset
|
26 #include "../Loaders/ILoadersContext.h" |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
27 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1381
diff
changeset
|
28 #include <OrthancException.h> |
815 | 29 |
1337
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1314
diff
changeset
|
30 namespace OrthancStone |
815 | 31 { |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
32 void LoaderStateMachine::State::Handle(const OrthancRestApiCommand::SuccessMessage& message) |
815 | 33 { |
34 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
35 } | |
36 | |
37 | |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
38 void LoaderStateMachine::State::Handle(const GetOrthancImageCommand::SuccessMessage& message) |
815 | 39 { |
40 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
41 } | |
42 | |
43 | |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
44 void LoaderStateMachine::State::Handle(const GetOrthancWebViewerJpegCommand::SuccessMessage& message) |
815 | 45 { |
46 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
47 } | |
48 | |
49 | |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
50 void LoaderStateMachine::Schedule(OracleCommandBase* command) |
815 | 51 { |
973
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
52 LOG(TRACE) << "LoaderStateMachine(" << std::hex << this << std::dec << ")::Schedule()"; |
964
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
956
diff
changeset
|
53 |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
54 std::unique_ptr<OracleCommandBase> protection(command); |
815 | 55 |
56 if (command == NULL) | |
57 { | |
58 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | |
59 } | |
60 | |
61 if (!command->HasPayload()) | |
62 { | |
63 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, | |
64 "The payload must contain the next state"); | |
65 } | |
66 pendingCommands_.push_back(protection.release()); | |
964
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
956
diff
changeset
|
67 |
815 | 68 Step(); |
69 } | |
70 | |
71 | |
72 void LoaderStateMachine::Start() | |
73 { | |
973
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
74 LOG(TRACE) << "LoaderStateMachine(" << std::hex << this << std::dec << ")::Start()"; |
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
75 |
815 | 76 if (active_) |
77 { | |
964
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
956
diff
changeset
|
78 LOG(TRACE) << "LoaderStateMachine::Start() called while active_ is true"; |
815 | 79 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
80 } | |
81 | |
82 active_ = true; | |
83 | |
84 for (size_t i = 0; i < simultaneousDownloads_; i++) | |
85 { | |
86 Step(); | |
87 } | |
88 } | |
89 | |
90 | |
91 void LoaderStateMachine::Step() | |
92 { | |
93 if (!pendingCommands_.empty() && | |
94 activeCommands_ < simultaneousDownloads_) | |
95 { | |
964
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
956
diff
changeset
|
96 |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
97 IOracleCommand* nextCommand = pendingCommands_.front(); |
964
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
956
diff
changeset
|
98 |
973
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
99 LOG(TRACE) << " LoaderStateMachine(" << std::hex << this << std::dec << |
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
100 ")::Step(): activeCommands_ (" << activeCommands_ << |
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
101 ") < simultaneousDownloads_ (" << simultaneousDownloads_ << |
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
102 ") --> will Schedule command addr " << std::hex << nextCommand << std::dec; |
964
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
956
diff
changeset
|
103 |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
104 { |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
105 std::unique_ptr<ILoadersContext::ILock> lock(loadersContext_.Lock()); |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
106 boost::shared_ptr<IObserver> observer(GetSharedObserver()); |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
107 lock->Schedule(observer, 0, nextCommand); // TODO: priority! |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
108 } |
815 | 109 pendingCommands_.pop_front(); |
110 | |
111 activeCommands_++; | |
112 } | |
964
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
956
diff
changeset
|
113 else |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
956
diff
changeset
|
114 { |
973
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
115 LOG(TRACE) << " LoaderStateMachine(" << std::hex << this << std::dec << |
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
116 ")::Step(): activeCommands_ (" << activeCommands_ << |
1061
eb28dfe432f7
fixed typo in assert. msg. + getters for custom windowing in grayscale layer configurator.
Benjamin Golinvaux <bgo@osimis.io>
parents:
977
diff
changeset
|
117 ") >= simultaneousDownloads_ (" << simultaneousDownloads_ << |
973
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
118 ") --> will NOT Schedule command"; |
964
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
956
diff
changeset
|
119 } |
815 | 120 } |
121 | |
122 | |
123 void LoaderStateMachine::Clear() | |
124 { | |
973
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
125 LOG(TRACE) << "LoaderStateMachine(" << std::hex << this << std::dec << ")::Clear()"; |
815 | 126 for (PendingCommands::iterator it = pendingCommands_.begin(); |
127 it != pendingCommands_.end(); ++it) | |
128 { | |
129 delete *it; | |
130 } | |
131 | |
132 pendingCommands_.clear(); | |
133 } | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
134 |
815 | 135 |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
136 void LoaderStateMachine::HandleExceptionMessage(const OracleCommandExceptionMessage& message) |
815 | 137 { |
1831
a03260db8835
Added SetCallerName to IOracleCommand to ease debugging
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
138 LOG(ERROR) << "LoaderStateMachine::HandleExceptionMessage: error in the state machine, stopping all processing. Caller: " |
a03260db8835
Added SetCallerName to IOracleCommand to ease debugging
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
139 << message.GetOrigin().GetCallerName(); |
840
47fc7919977d
Added details on errors in LoaderStateMachine + dummy change in loader.cpp
Benjamin Golinvaux <bgo@osimis.io>
parents:
815
diff
changeset
|
140 LOG(ERROR) << "Error: " << message.GetException().What() << " Details: " << |
47fc7919977d
Added details on errors in LoaderStateMachine + dummy change in loader.cpp
Benjamin Golinvaux <bgo@osimis.io>
parents:
815
diff
changeset
|
141 message.GetException().GetDetails(); |
1831
a03260db8835
Added SetCallerName to IOracleCommand to ease debugging
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
142 Clear(); |
815 | 143 } |
144 | |
145 template <typename T> | |
146 void LoaderStateMachine::HandleSuccessMessage(const T& message) | |
147 { | |
1571 | 148 if (activeCommands_ == 0) { |
973
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
149 LOG(ERROR) << "LoaderStateMachine(" << std::hex << this << std::dec << ")::HandleSuccessMessage : activeCommands_ should be > 0 but is: " << activeCommands_; |
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
150 } |
975
e75fd08d6c75
Cleaning in ICallable + changed fingerprint to plain char array to allow for
Benjamin Golinvaux <bgo@osimis.io>
parents:
973
diff
changeset
|
151 else { |
e75fd08d6c75
Cleaning in ICallable + changed fingerprint to plain char array to allow for
Benjamin Golinvaux <bgo@osimis.io>
parents:
973
diff
changeset
|
152 activeCommands_--; |
e75fd08d6c75
Cleaning in ICallable + changed fingerprint to plain char array to allow for
Benjamin Golinvaux <bgo@osimis.io>
parents:
973
diff
changeset
|
153 try |
e75fd08d6c75
Cleaning in ICallable + changed fingerprint to plain char array to allow for
Benjamin Golinvaux <bgo@osimis.io>
parents:
973
diff
changeset
|
154 { |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
155 dynamic_cast<State&>(message.GetOrigin().GetPayload()).Handle(message); |
975
e75fd08d6c75
Cleaning in ICallable + changed fingerprint to plain char array to allow for
Benjamin Golinvaux <bgo@osimis.io>
parents:
973
diff
changeset
|
156 Step(); |
e75fd08d6c75
Cleaning in ICallable + changed fingerprint to plain char array to allow for
Benjamin Golinvaux <bgo@osimis.io>
parents:
973
diff
changeset
|
157 } |
e75fd08d6c75
Cleaning in ICallable + changed fingerprint to plain char array to allow for
Benjamin Golinvaux <bgo@osimis.io>
parents:
973
diff
changeset
|
158 catch (Orthanc::OrthancException& e) |
e75fd08d6c75
Cleaning in ICallable + changed fingerprint to plain char array to allow for
Benjamin Golinvaux <bgo@osimis.io>
parents:
973
diff
changeset
|
159 { |
1831
a03260db8835
Added SetCallerName to IOracleCommand to ease debugging
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
160 LOG(ERROR) << "Error in the state machine, stopping all processing. Caller: " << |
a03260db8835
Added SetCallerName to IOracleCommand to ease debugging
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
161 message.GetOrigin().GetCallerName() << ". Error: " << e.What() << " Details: " << e.GetDetails(); |
975
e75fd08d6c75
Cleaning in ICallable + changed fingerprint to plain char array to allow for
Benjamin Golinvaux <bgo@osimis.io>
parents:
973
diff
changeset
|
162 Clear(); |
e75fd08d6c75
Cleaning in ICallable + changed fingerprint to plain char array to allow for
Benjamin Golinvaux <bgo@osimis.io>
parents:
973
diff
changeset
|
163 } |
815 | 164 } |
165 } | |
166 | |
167 | |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
168 LoaderStateMachine::LoaderStateMachine( |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
169 ILoadersContext& loadersContext) |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
170 : loadersContext_(loadersContext) |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
171 , active_(false) |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
172 , simultaneousDownloads_(4) |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
173 , activeCommands_(0) |
815 | 174 { |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
175 LOG(TRACE) << "LoaderStateMachine(" << std::hex << this |
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
176 << std::dec << ")::LoaderStateMachine()"; |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
177 } |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
178 |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
179 void LoaderStateMachine::PostConstructor() |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
180 { |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
181 std::unique_ptr<ILoadersContext::ILock> |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
182 lock(loadersContext_.Lock()); |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
183 |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
184 IObservable& observable = lock->GetOracleObservable(); |
973
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
185 |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
186 // TODO => Move this out of constructor |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
187 Register<OrthancRestApiCommand::SuccessMessage>( |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
188 observable, &LoaderStateMachine::HandleSuccessMessage); |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
189 Register<GetOrthancImageCommand::SuccessMessage>( |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
190 observable, &LoaderStateMachine::HandleSuccessMessage); |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
191 Register<GetOrthancWebViewerJpegCommand::SuccessMessage>( |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
192 observable, &LoaderStateMachine::HandleSuccessMessage); |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
193 Register<OracleCommandExceptionMessage>( |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
194 observable, &LoaderStateMachine::HandleExceptionMessage); |
815 | 195 } |
196 | |
973
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
197 LoaderStateMachine::~LoaderStateMachine() |
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
198 { |
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
199 LOG(TRACE) << "LoaderStateMachine(" << std::hex << this << std::dec << ")::~LoaderStateMachine()"; |
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
200 Clear(); |
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
964
diff
changeset
|
201 } |
815 | 202 |
203 void LoaderStateMachine::SetSimultaneousDownloads(unsigned int count) | |
204 { | |
205 if (active_) | |
206 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
840
diff
changeset
|
207 LOG(ERROR) << "LoaderStateMachine::SetSimultaneousDownloads called while active_ is true"; |
815 | 208 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
209 } | |
210 else if (count == 0) | |
211 { | |
212 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
213 } | |
214 else | |
215 { | |
216 simultaneousDownloads_ = count; | |
217 } | |
218 } | |
219 } |