annotate OrthancFramework/Sources/JobsEngine/Operations/JobOperationValues.cpp @ 4733:1db3b79d97bd

Error code and description of jobs are now saved into the Orthanc database
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 28 Jun 2021 14:25:37 +0200
parents d9473bd5ed43
children 7053502fbf97
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4437
d9473bd5ed43 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4348
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
10 * the License, or (at your option) any later version.
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
15 * Lesser General Public License for more details.
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
18 * License along with this program. If not, see
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
19 * <http://www.gnu.org/licenses/>.
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "../../PrecompiledHeaders.h"
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "JobOperationValues.h"
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
2621
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
26 #include "../IJobUnserializer.h"
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "../../OrthancException.h"
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include <cassert>
2621
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
30 #include <memory>
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 namespace Orthanc
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
4348
93c281752e7a reintroduced backward ABI compatibility in Orthanc Framework .so for unit tests of Orthanc 1.7.2 to 1.8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
34 #if ORTHANC_BUILDING_FRAMEWORK_LIBRARY == 1
93c281752e7a reintroduced backward ABI compatibility in Orthanc Framework .so for unit tests of Orthanc 1.7.2 to 1.8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
35 void JobOperationValues::Append(JobOperationValue* value)
93c281752e7a reintroduced backward ABI compatibility in Orthanc Framework .so for unit tests of Orthanc 1.7.2 to 1.8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
36 {
93c281752e7a reintroduced backward ABI compatibility in Orthanc Framework .so for unit tests of Orthanc 1.7.2 to 1.8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
37 throw OrthancException(ErrorCode_DiscontinuedAbi, "Removed in 1.8.1");
93c281752e7a reintroduced backward ABI compatibility in Orthanc Framework .so for unit tests of Orthanc 1.7.2 to 1.8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
38 }
93c281752e7a reintroduced backward ABI compatibility in Orthanc Framework .so for unit tests of Orthanc 1.7.2 to 1.8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
39 #endif
93c281752e7a reintroduced backward ABI compatibility in Orthanc Framework .so for unit tests of Orthanc 1.7.2 to 1.8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
40
93c281752e7a reintroduced backward ABI compatibility in Orthanc Framework .so for unit tests of Orthanc 1.7.2 to 1.8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
41
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 void JobOperationValues::Append(JobOperationValues& target,
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 bool clear)
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 target.Reserve(target.GetSize() + GetSize());
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 for (size_t i = 0; i < values_.size(); i++)
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 if (clear)
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 target.Append(values_[i]);
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 values_[i] = NULL;
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 else
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 target.Append(GetValue(i).Clone());
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 if (clear)
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 Clear();
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
66 JobOperationValues::~JobOperationValues()
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
67 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
68 Clear();
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
69 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
70
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
71 void JobOperationValues::Move(JobOperationValues &target)
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
72 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
73 return Append(target, true);
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
74 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
75
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
76 void JobOperationValues::Copy(JobOperationValues &target)
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
77 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
78 return Append(target, false);
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
79 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
80
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 void JobOperationValues::Clear()
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 for (size_t i = 0; i < values_.size(); i++)
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 if (values_[i] != NULL)
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 delete values_[i];
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 values_.clear();
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
95 void JobOperationValues::Reserve(size_t count)
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
96 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
97 values_.reserve(count);
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
98 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
99
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
4310
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
101 void JobOperationValues::Append(IJobOperationValue* value) // Takes ownership
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 if (value == NULL)
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 throw OrthancException(ErrorCode_NullPointer);
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 else
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 values_.push_back(value);
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
113 size_t JobOperationValues::GetSize() const
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
114 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
115 return values_.size();
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
116 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
117
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118
4310
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
119 IJobOperationValue& JobOperationValues::GetValue(size_t index) const
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 if (index >= values_.size())
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 throw OrthancException(ErrorCode_ParameterOutOfRange);
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 else
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 assert(values_[index] != NULL);
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 return *values_[index];
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 }
2616
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
131
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
132
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
133 void JobOperationValues::Serialize(Json::Value& target) const
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
134 {
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
135 target = Json::arrayValue;
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
136
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
137 for (size_t i = 0; i < values_.size(); i++)
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
138 {
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
139 Json::Value tmp;
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
140 values_[i]->Serialize(tmp);
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
141 target.append(tmp);
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
142 }
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
143 }
2621
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
144
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
145
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2621
diff changeset
146 JobOperationValues* JobOperationValues::Unserialize(IJobUnserializer& unserializer,
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2621
diff changeset
147 const Json::Value& source)
2621
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
148 {
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
149 if (source.type() != Json::arrayValue)
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
150 {
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
151 throw OrthancException(ErrorCode_BadFileFormat);
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
152 }
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
153
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
154 std::unique_ptr<JobOperationValues> result(new JobOperationValues);
2621
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
155
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
156 result->Reserve(source.size());
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
157
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
158 for (Json::Value::ArrayIndex i = 0; i < source.size(); i++)
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
159 {
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
160 result->Append(unserializer.UnserializeValue(source[i]));
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
161 }
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
162
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
163 return result.release();
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
164 }
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 }