comparison OrthancFramework/Sources/JobsEngine/SetOfCommandsJob.cpp @ 4300:b30a8de92ad9

abi continued
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 05 Nov 2020 19:33:18 +0100
parents bf7b9edf6b81
children 44b53a2c0a13
comparison
equal deleted inserted replaced
4299:3f85db78c441 4300:b30a8de92ad9
30 #include <cassert> 30 #include <cassert>
31 #include <memory> 31 #include <memory>
32 32
33 namespace Orthanc 33 namespace Orthanc
34 { 34 {
35 SetOfCommandsJob::ICommand::~ICommand()
36 {
37 }
38
39 SetOfCommandsJob::ICommandUnserializer::~ICommandUnserializer()
40 {
41 }
42
35 SetOfCommandsJob::SetOfCommandsJob() : 43 SetOfCommandsJob::SetOfCommandsJob() :
36 started_(false), 44 started_(false),
37 permissive_(false), 45 permissive_(false),
38 position_(0) 46 position_(0)
39 { 47 {
47 assert(commands_[i] != NULL); 55 assert(commands_[i] != NULL);
48 delete commands_[i]; 56 delete commands_[i];
49 } 57 }
50 } 58 }
51 59
52 60 size_t SetOfCommandsJob::GetPosition() const
61 {
62 return position_;
63 }
64
65 void SetOfCommandsJob::SetDescription(const std::string &description)
66 {
67 description_ = description;
68 }
69
70
53 void SetOfCommandsJob::Reserve(size_t size) 71 void SetOfCommandsJob::Reserve(size_t size)
54 { 72 {
55 if (started_) 73 if (started_)
56 { 74 {
57 throw OrthancException(ErrorCode_BadSequenceOfCalls); 75 throw OrthancException(ErrorCode_BadSequenceOfCalls);
60 { 78 {
61 commands_.reserve(size); 79 commands_.reserve(size);
62 } 80 }
63 } 81 }
64 82
65 83 size_t SetOfCommandsJob::GetCommandsCount() const
84 {
85 return commands_.size();
86 }
87
88
66 void SetOfCommandsJob::AddCommand(ICommand* command) 89 void SetOfCommandsJob::AddCommand(ICommand* command)
67 { 90 {
68 if (command == NULL) 91 if (command == NULL)
69 { 92 {
70 throw OrthancException(ErrorCode_NullPointer); 93 throw OrthancException(ErrorCode_NullPointer);
77 { 100 {
78 commands_.push_back(command); 101 commands_.push_back(command);
79 } 102 }
80 } 103 }
81 104
105 bool SetOfCommandsJob::IsPermissive() const
106 {
107 return permissive_;
108 }
109
82 110
83 void SetOfCommandsJob::SetPermissive(bool permissive) 111 void SetOfCommandsJob::SetPermissive(bool permissive)
84 { 112 {
85 if (started_) 113 if (started_)
86 { 114 {
103 { 131 {
104 throw OrthancException(ErrorCode_BadSequenceOfCalls); 132 throw OrthancException(ErrorCode_BadSequenceOfCalls);
105 } 133 }
106 } 134 }
107 135
108 136 void SetOfCommandsJob::Start()
137 {
138 started_ = true;
139 }
140
141
109 float SetOfCommandsJob::GetProgress() 142 float SetOfCommandsJob::GetProgress()
110 { 143 {
111 if (commands_.empty()) 144 if (commands_.empty())
112 { 145 {
113 return 1; 146 return 1;
115 else 148 else
116 { 149 {
117 return (static_cast<float>(position_) / 150 return (static_cast<float>(position_) /
118 static_cast<float>(commands_.size())); 151 static_cast<float>(commands_.size()));
119 } 152 }
153 }
154
155 bool SetOfCommandsJob::IsStarted() const
156 {
157 return started_;
120 } 158 }
121 159
122 160
123 const SetOfCommandsJob::ICommand& SetOfCommandsJob::GetCommand(size_t index) const 161 const SetOfCommandsJob::ICommand& SetOfCommandsJob::GetCommand(size_t index) const
124 { 162 {
232 } 270 }
233 271
234 return true; 272 return true;
235 } 273 }
236 274
275 bool SetOfCommandsJob::GetOutput(std::string &output,
276 MimeType &mime,
277 const std::string &key)
278 {
279 return false;
280 }
281
237 282
238 SetOfCommandsJob::SetOfCommandsJob(ICommandUnserializer* unserializer, 283 SetOfCommandsJob::SetOfCommandsJob(ICommandUnserializer* unserializer,
239 const Json::Value& source) : 284 const Json::Value& source) :
240 started_(false) 285 started_(false)
241 { 286 {