annotate OrthancFramework/Sources/JobsEngine/Operations/JobOperationValues.cpp @ 5185:0ea402b4d901

upgrade to year 2023
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 25 Mar 2023 12:27:21 +0100
parents 43e613a7756b
children 48b8dae6dc77
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
5185
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * 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
9 * 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
10 * 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
11 * the License, or (at your option) any later version.
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * 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
16 * Lesser General Public License for more details.
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
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
18 * 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
19 * 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
20 * <http://www.gnu.org/licenses/>.
2601
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
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "../../PrecompiledHeaders.h"
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "JobOperationValues.h"
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
2621
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
27 #include "../IJobUnserializer.h"
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include "../../OrthancException.h"
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include <cassert>
2621
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
31 #include <memory>
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 namespace Orthanc
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
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
35 #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
36 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
37 {
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 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
39 }
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 #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
41
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
42
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 void JobOperationValues::Append(JobOperationValues& target,
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 bool clear)
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 target.Reserve(target.GetSize() + GetSize());
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 for (size_t i = 0; i < values_.size(); i++)
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 if (clear)
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 target.Append(values_[i]);
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 values_[i] = NULL;
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 else
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 target.Append(GetValue(i).Clone());
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
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 if (clear)
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 Clear();
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
67 JobOperationValues::~JobOperationValues()
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
68 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
69 Clear();
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
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
72 void JobOperationValues::Move(JobOperationValues &target)
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
73 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
74 return Append(target, true);
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
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
77 void JobOperationValues::Copy(JobOperationValues &target)
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
78 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
79 return Append(target, false);
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
80 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
81
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 void JobOperationValues::Clear()
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 for (size_t i = 0; i < values_.size(); i++)
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 if (values_[i] != NULL)
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 delete values_[i];
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
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 values_.clear();
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
96 void JobOperationValues::Reserve(size_t count)
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
97 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
98 values_.reserve(count);
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
99 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
100
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
4310
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
102 void JobOperationValues::Append(IJobOperationValue* value) // Takes ownership
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 if (value == NULL)
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 throw OrthancException(ErrorCode_NullPointer);
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 else
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 values_.push_back(value);
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
114 size_t JobOperationValues::GetSize() const
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
115 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
116 return values_.size();
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
117 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
118
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
4310
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
120 IJobOperationValue& JobOperationValues::GetValue(size_t index) const
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 if (index >= values_.size())
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 throw OrthancException(ErrorCode_ParameterOutOfRange);
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 else
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 {
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 assert(values_[index] != NULL);
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 return *values_[index];
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 }
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 }
2616
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
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
134 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
135 {
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
136 target = Json::arrayValue;
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
137
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
138 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
139 {
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
140 Json::Value tmp;
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
141 values_[i]->Serialize(tmp);
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
142 target.append(tmp);
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
143 }
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2601
diff changeset
144 }
2621
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
145
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
146
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2621
diff changeset
147 JobOperationValues* JobOperationValues::Unserialize(IJobUnserializer& unserializer,
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2621
diff changeset
148 const Json::Value& source)
2621
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
149 {
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
150 if (source.type() != Json::arrayValue)
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
151 {
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
152 throw OrthancException(ErrorCode_BadFileFormat);
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
153 }
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
154
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
155 std::unique_ptr<JobOperationValues> result(new JobOperationValues);
2621
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
156
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
157 result->Reserve(source.size());
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
158
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
159 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
160 {
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
161 result->Append(unserializer.UnserializeValue(source[i]));
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
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
164 return result.release();
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
165 }
2601
5b6c3d77a2a1 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 }