annotate Plugins/Engine/PluginsJob.cpp @ 2811:7cfc8d266f41

reason for releasing resources in jobs
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 06 Sep 2018 12:32:02 +0200
parents 1e8c4ecd02f4
children ea7aea6f6a95
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2810
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "../../OrthancServer/PrecompiledHeadersServer.h"
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "PluginsJob.h"
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #if ORTHANC_ENABLE_PLUGINS != 1
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #error The plugin support is disabled
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 #endif
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include "../../Core/OrthancException.h"
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 #include <json/reader.h>
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 #include <cassert>
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 namespace Orthanc
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 PluginsJob::PluginsJob(const _OrthancPluginSubmitJob& parameters) :
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 job_(parameters.job_),
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 free_(parameters.free_),
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 getProgress_(parameters.getProgress_),
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 step_(parameters.step_),
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 releaseResources_(parameters.releaseResources_),
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 reset_(parameters.reset_)
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 {
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 if (job_ == NULL ||
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 parameters.type_ == NULL ||
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 free_ == NULL ||
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 getProgress_ == NULL ||
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 step_ == NULL ||
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 releaseResources_ == NULL ||
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 reset_ == NULL)
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 {
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 throw OrthancException(ErrorCode_NullPointer);
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 }
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 type_.assign(parameters.type_);
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 if (parameters.content_ == NULL)
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 {
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 publicContent_ = Json::objectValue;
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 }
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 else
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 Json::Reader reader;
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 if (!reader.parse(parameters.content_, publicContent_) ||
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 publicContent_.type() != Json::objectValue)
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 {
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 free_(job_);
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 throw OrthancException(ErrorCode_BadFileFormat);
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 }
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 }
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 if (parameters.serialized_ == NULL)
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 {
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 hasSerialized_ = false;
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 }
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 else
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 {
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 hasSerialized_ = true;
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 Json::Reader reader;
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 if (!reader.parse(parameters.serialized_, serialized_) ||
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 serialized_.type() != Json::objectValue ||
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 !serialized_.isMember("Type") ||
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 serialized_["Type"].type() != Json::stringValue)
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 {
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 free_(job_);
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 throw OrthancException(ErrorCode_BadFileFormat);
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 }
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 }
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 PluginsJob::~PluginsJob()
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 {
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 assert(job_ != NULL);
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 free_(job_);
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 }
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 JobStepResult PluginsJob::ExecuteStep()
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
2811
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
113 OrthancPluginJobStepStatus status = step_(job_);
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
114
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
115 switch (status)
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
116 {
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
117 case OrthancPluginJobStepStatus_Success:
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
118 return JobStepResult::Success();
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
119
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
120 case OrthancPluginJobStepStatus_Failure:
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
121 return JobStepResult::Failure(ErrorCode_Plugin);
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
122
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
123 case OrthancPluginJobStepStatus_Continue:
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
124 return JobStepResult::Continue();
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
125
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
126 default:
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
127 throw OrthancException(ErrorCode_ParameterOutOfRange);
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
128 }
2810
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 void PluginsJob::SignalResubmit()
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 {
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 reset_(job_);
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 }
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135
2811
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
136 void PluginsJob::ReleaseResources(JobReleaseReason reason)
2810
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 {
2811
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
138 switch (reason)
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
139 {
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
140 case JobReleaseReason_Success:
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
141 releaseResources_(job_, OrthancPluginJobReleaseReason_Success);
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
142 break;
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
143
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
144 case JobReleaseReason_Failure:
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
145 releaseResources_(job_, OrthancPluginJobReleaseReason_Failure);
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
146 break;
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
147
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
148 case JobReleaseReason_Canceled:
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
149 releaseResources_(job_, OrthancPluginJobReleaseReason_Canceled);
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
150 break;
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
151
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
152 case JobReleaseReason_Paused:
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
153 releaseResources_(job_, OrthancPluginJobReleaseReason_Paused);
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
154 break;
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
155
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
156 default:
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
157 throw OrthancException(ErrorCode_ParameterOutOfRange);
7cfc8d266f41 reason for releasing resources in jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2810
diff changeset
158 }
2810
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 }
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 float PluginsJob::GetProgress()
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 {
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 return getProgress_(job_);
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 }
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 bool PluginsJob::Serialize(Json::Value& value)
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 {
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 if (hasSerialized_)
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 {
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 value = serialized_;
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 return true;
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 }
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 else
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 {
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 return false;
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 }
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 }
1e8c4ecd02f4 missing files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 }