annotate OrthancFramework/Sources/JobsEngine/Operations/JobOperationValues.cpp @ 5853:4d932683049d get-scu tip

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