Mercurial > hg > orthanc
comparison UnitTestsSources/MultiThreadingTests.cpp @ 2924:22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 09 Nov 2018 09:06:46 +0100 |
parents | 9d08edde614b |
children | dc18d5804746 |
comparison
equal
deleted
inserted
replaced
2923:87366b8aed4f | 2924:22524fd06225 |
---|---|
91 count_(0), | 91 count_(0), |
92 steps_(4) | 92 steps_(4) |
93 { | 93 { |
94 } | 94 } |
95 | 95 |
96 virtual void Start() | 96 virtual void Start() ORTHANC_OVERRIDE |
97 { | 97 { |
98 } | 98 } |
99 | 99 |
100 virtual void Reset() | 100 virtual void Reset() ORTHANC_OVERRIDE |
101 { | 101 { |
102 } | 102 } |
103 | 103 |
104 virtual JobStepResult Step() | 104 virtual JobStepResult Step() ORTHANC_OVERRIDE |
105 { | 105 { |
106 if (fails_) | 106 if (fails_) |
107 { | 107 { |
108 return JobStepResult::Failure(ErrorCode_ParameterOutOfRange); | 108 return JobStepResult::Failure(ErrorCode_ParameterOutOfRange); |
109 } | 109 } |
116 count_++; | 116 count_++; |
117 return JobStepResult::Continue(); | 117 return JobStepResult::Continue(); |
118 } | 118 } |
119 } | 119 } |
120 | 120 |
121 virtual void Stop(JobStopReason reason) | 121 virtual void Stop(JobStopReason reason) ORTHANC_OVERRIDE |
122 { | 122 { |
123 } | 123 } |
124 | 124 |
125 virtual float GetProgress() | 125 virtual float GetProgress() ORTHANC_OVERRIDE |
126 { | 126 { |
127 return static_cast<float>(count_) / static_cast<float>(steps_ - 1); | 127 return static_cast<float>(count_) / static_cast<float>(steps_ - 1); |
128 } | 128 } |
129 | 129 |
130 virtual void GetJobType(std::string& type) | 130 virtual void GetJobType(std::string& type) ORTHANC_OVERRIDE |
131 { | 131 { |
132 type = "DummyJob"; | 132 type = "DummyJob"; |
133 } | 133 } |
134 | 134 |
135 virtual bool Serialize(Json::Value& value) | 135 virtual bool Serialize(Json::Value& value) ORTHANC_OVERRIDE |
136 { | 136 { |
137 value = Json::objectValue; | 137 value = Json::objectValue; |
138 value["Type"] = "DummyJob"; | 138 value["Type"] = "DummyJob"; |
139 return true; | 139 return true; |
140 } | 140 } |
141 | 141 |
142 virtual void GetPublicContent(Json::Value& value) | 142 virtual void GetPublicContent(Json::Value& value) ORTHANC_OVERRIDE |
143 { | 143 { |
144 value["hello"] = "world"; | 144 value["hello"] = "world"; |
145 } | 145 } |
146 }; | 146 }; |
147 | 147 |
150 { | 150 { |
151 private: | 151 private: |
152 bool trailingStepDone_; | 152 bool trailingStepDone_; |
153 | 153 |
154 protected: | 154 protected: |
155 virtual bool HandleInstance(const std::string& instance) | 155 virtual bool HandleInstance(const std::string& instance) ORTHANC_OVERRIDE |
156 { | 156 { |
157 return (instance != "nope"); | 157 return (instance != "nope"); |
158 } | 158 } |
159 | 159 |
160 virtual bool HandleTrailingStep() | 160 virtual bool HandleTrailingStep() ORTHANC_OVERRIDE |
161 { | 161 { |
162 if (HasTrailingStep()) | 162 if (HasTrailingStep()) |
163 { | 163 { |
164 if (trailingStepDone_) | 164 if (trailingStepDone_) |
165 { | 165 { |
199 bool IsTrailingStepDone() const | 199 bool IsTrailingStepDone() const |
200 { | 200 { |
201 return trailingStepDone_; | 201 return trailingStepDone_; |
202 } | 202 } |
203 | 203 |
204 virtual void Stop(JobStopReason reason) | 204 virtual void Stop(JobStopReason reason) ORTHANC_OVERRIDE |
205 { | 205 { |
206 } | 206 } |
207 | 207 |
208 virtual void GetJobType(std::string& s) | 208 virtual void GetJobType(std::string& s) ORTHANC_OVERRIDE |
209 { | 209 { |
210 s = "DummyInstancesJob"; | 210 s = "DummyInstancesJob"; |
211 } | 211 } |
212 }; | 212 }; |
213 | 213 |
214 | 214 |
215 class DummyUnserializer : public GenericJobUnserializer | 215 class DummyUnserializer : public GenericJobUnserializer |
216 { | 216 { |
217 public: | 217 public: |
218 virtual IJob* UnserializeJob(const Json::Value& value) | 218 virtual IJob* UnserializeJob(const Json::Value& value) ORTHANC_OVERRIDE |
219 { | 219 { |
220 if (SerializationToolbox::ReadString(value, "Type") == "DummyInstancesJob") | 220 if (SerializationToolbox::ReadString(value, "Type") == "DummyInstancesJob") |
221 { | 221 { |
222 return new DummyInstancesJob(value); | 222 return new DummyInstancesJob(value); |
223 } | 223 } |
1284 db_.Open(); | 1284 db_.Open(); |
1285 context_.reset(new ServerContext(db_, storage_, true /* running unit tests */)); | 1285 context_.reset(new ServerContext(db_, storage_, true /* running unit tests */)); |
1286 context_->SetupJobsEngine(true, false); | 1286 context_->SetupJobsEngine(true, false); |
1287 } | 1287 } |
1288 | 1288 |
1289 virtual ~OrthancJobsSerialization() | 1289 virtual ~OrthancJobsSerialization() ORTHANC_OVERRIDE |
1290 { | 1290 { |
1291 context_->Stop(); | 1291 context_->Stop(); |
1292 context_.reset(NULL); | 1292 context_.reset(NULL); |
1293 db_.Close(); | 1293 db_.Close(); |
1294 } | 1294 } |