annotate Core/JobsEngine/SetOfCommandsJob.h @ 2919:2ca9cd064b15

PamReader::ReadFromMemory
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 06 Nov 2018 15:41:21 +0100
parents 8b00e4cb4a6b
children cb5d75143da0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #pragma once
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "IJob.h"
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include <set>
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 namespace Orthanc
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 class SetOfCommandsJob : public IJob
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 {
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 public:
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 class ICommand : public boost::noncopyable
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 public:
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 virtual ~ICommand()
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 {
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 }
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 virtual bool Execute() = 0;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 virtual void Serialize(Json::Value& target) const = 0;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 };
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 class ICommandUnserializer : public boost::noncopyable
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 public:
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 virtual ~ICommandUnserializer()
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 {
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 }
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 virtual ICommand* Unserialize(const Json::Value& source) const = 0;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 };
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 private:
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 bool started_;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 std::vector<ICommand*> commands_;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 bool permissive_;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 size_t position_;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 std::string description_;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 public:
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 SetOfCommandsJob();
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 SetOfCommandsJob(ICommandUnserializer* unserializer /* takes ownership */,
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 const Json::Value& source);
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 virtual ~SetOfCommandsJob();
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 size_t GetPosition() const
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 return position_;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 }
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 void SetDescription(const std::string& description)
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 description_ = description;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 const std::string& GetDescription() const
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 {
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 return description_;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 }
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 void Reserve(size_t size);
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 size_t GetCommandsCount() const
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 {
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 return commands_.size();
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 void AddCommand(ICommand* command); // Takes ownership
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 bool IsPermissive() const
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 {
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 return permissive_;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 }
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 void SetPermissive(bool permissive);
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 virtual void Reset();
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 virtual void Start()
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 {
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 started_ = true;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 }
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 virtual float GetProgress();
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 bool IsStarted() const
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 {
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 return started_;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 const ICommand& GetCommand(size_t index) const;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 virtual JobStepResult Step();
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 virtual void GetPublicContent(Json::Value& value);
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 virtual bool Serialize(Json::Value& target);
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 };
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 }