comparison Core/JobsEngine/SetOfInstancesJob.cpp @ 2598:34dc57f4a7d2 jobs

simplification of JobStepResult
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 16 May 2018 16:23:20 +0200
parents ec09641d6f41
children 714dcddeb65f
comparison
equal deleted inserted replaced
2597:ef7ba1b21d58 2598:34dc57f4a7d2
111 static_cast<float>(instances_.size())); 111 static_cast<float>(instances_.size()));
112 } 112 }
113 } 113 }
114 114
115 115
116 JobStepResult* SetOfInstancesJob::ExecuteStep() 116 JobStepResult SetOfInstancesJob::ExecuteStep()
117 { 117 {
118 if (!started_) 118 if (!started_)
119 { 119 {
120 throw OrthancException(ErrorCode_InternalError); 120 throw OrthancException(ErrorCode_InternalError);
121 } 121 }
123 if (instances_.empty() && 123 if (instances_.empty() &&
124 position_ == 0) 124 position_ == 0)
125 { 125 {
126 // No instance to handle, we're done 126 // No instance to handle, we're done
127 position_ = 1; 127 position_ = 1;
128 return new JobStepResult(JobStepCode_Success); 128 return JobStepResult::Success();
129 } 129 }
130 130
131 if (position_ >= instances_.size()) 131 if (position_ >= instances_.size())
132 { 132 {
133 // Already done 133 // Already done
134 return new JobStepResult(JobStepCode_Failure); 134 throw OrthancException(ErrorCode_BadSequenceOfCalls);
135 } 135 }
136 136
137 const std::string currentInstance = instances_[position_]; 137 const std::string currentInstance = instances_[position_];
138 138
139 bool ok; 139 bool ok;
142 { 142 {
143 ok = HandleInstance(currentInstance); 143 ok = HandleInstance(currentInstance);
144 144
145 if (!ok && !permissive_) 145 if (!ok && !permissive_)
146 { 146 {
147 throw OrthancException(ErrorCode_InternalError); 147 return JobStepResult::Failure(ErrorCode_InternalError);
148 } 148 }
149 } 149 }
150 catch (OrthancException& e) 150 catch (OrthancException& e)
151 { 151 {
152 if (permissive_) 152 if (permissive_)
167 position_ += 1; 167 position_ += 1;
168 168
169 if (position_ == instances_.size()) 169 if (position_ == instances_.size())
170 { 170 {
171 // We're done 171 // We're done
172 return new JobStepResult(JobStepCode_Success); 172 return JobStepResult::Success();
173 } 173 }
174 else 174 else
175 { 175 {
176 return new JobStepResult(JobStepCode_Continue); 176 return JobStepResult::Continue();
177 } 177 }
178 } 178 }
179 179
180 180
181 void SetOfInstancesJob::GetInternalContent(Json::Value& value) 181 void SetOfInstancesJob::GetInternalContent(Json::Value& value)