Mercurial > hg > orthanc-stone
annotate Framework/Deprecated/Loaders/LoaderStateMachine.h @ 1327:4f8db2d202c8 broker
OrthancSeriesProgressiveLoader now has two modes that
can be selected at object creation :
- progressive (will first load jpeg50, then jpeg90 then PAM)
- non-progressive (will directly load PAM (uncompressed))
Please note that the slice loading order remains dynamic
and depending upon the slice that the client code wishes
to extract from the volume.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 25 Mar 2020 14:34:27 +0100 |
parents | 9b126de2cde2 |
children |
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 | |
1271
0ca50d275b9a
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1225
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
815 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
24 #include "../../Messages/IObservable.h" |
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
25 #include "../../Messages/ObserverBase.h" |
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
26 #include "../../Oracle/GetOrthancImageCommand.h" |
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
27 #include "../../Oracle/GetOrthancWebViewerJpegCommand.h" |
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
28 #include "../../Oracle/IOracle.h" |
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
29 #include "../../Oracle/OracleCommandExceptionMessage.h" |
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
30 #include "../../Oracle/OrthancRestApiCommand.h" |
815 | 31 |
32 #include <Core/IDynamicObject.h> | |
33 | |
34 #include <list> | |
35 | |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
36 namespace OrthancStone |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
37 { |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
38 class ILoadersContext; |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
39 } |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
40 |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
41 namespace Deprecated |
815 | 42 { |
43 /** | |
44 This class is supplied with Oracle commands and will schedule up to | |
45 simultaneousDownloads_ of them at the same time, then will schedule the | |
46 rest once slots become available. It is used, a.o., by the | |
47 OrtancMultiframeVolumeLoader class. | |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
48 |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
49 To use it, you need to create commands that derive from State. |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
50 |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
51 You need to initialize them with the object that must be called when |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
52 an answer is received. |
815 | 53 */ |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
54 |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
55 class LoaderStateMachine : public OrthancStone::ObserverBase<LoaderStateMachine> |
815 | 56 { |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
57 public: |
815 | 58 class State : public Orthanc::IDynamicObject |
59 { | |
60 private: | |
61 LoaderStateMachine& that_; | |
62 | |
63 public: | |
64 State(LoaderStateMachine& that) : | |
65 that_(that) | |
66 { | |
67 } | |
68 | |
69 State(const State& currentState) : | |
70 that_(currentState.that_) | |
71 { | |
72 } | |
73 | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
74 void Schedule(OrthancStone::OracleCommandBase* command) const |
815 | 75 { |
76 that_.Schedule(command); | |
77 } | |
78 | |
79 template <typename T> | |
80 T& GetLoader() const | |
81 { | |
82 return dynamic_cast<T&>(that_); | |
83 } | |
84 | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
85 virtual void Handle(const OrthancStone::OrthancRestApiCommand::SuccessMessage& message); |
815 | 86 |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
87 virtual void Handle(const OrthancStone::GetOrthancImageCommand::SuccessMessage& message); |
815 | 88 |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
89 virtual void Handle(const OrthancStone::GetOrthancWebViewerJpegCommand::SuccessMessage& message); |
815 | 90 }; |
91 | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
92 void Schedule(OrthancStone::OracleCommandBase* command); |
815 | 93 |
94 void Start(); | |
95 | |
96 private: | |
97 void Step(); | |
98 | |
99 void Clear(); | |
100 | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
101 void HandleExceptionMessage(const OrthancStone::OracleCommandExceptionMessage& message); |
815 | 102 |
103 template <typename T> | |
104 void HandleSuccessMessage(const T& message); | |
105 | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1128
diff
changeset
|
106 typedef std::list<OrthancStone::IOracleCommand*> PendingCommands; |
815 | 107 |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
108 OrthancStone::ILoadersContext& loadersContext_; |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
109 bool active_; |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
110 unsigned int simultaneousDownloads_; |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
111 PendingCommands pendingCommands_; |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
112 unsigned int activeCommands_; |
815 | 113 |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
114 |
815 | 115 public: |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
116 LoaderStateMachine(OrthancStone::ILoadersContext& loadersContext); |
815 | 117 |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
118 void PostConstructor(); |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
119 |
973
38409549db43
Log with addresses + added fingerprint mechanism to avoid calling zombie objects
Benjamin Golinvaux <bgo@osimis.io>
parents:
815
diff
changeset
|
120 virtual ~LoaderStateMachine(); |
815 | 121 |
122 bool IsActive() const | |
123 { | |
124 return active_; | |
125 } | |
126 | |
127 void SetSimultaneousDownloads(unsigned int count); | |
128 }; | |
129 } |