Mercurial > hg > orthanc
annotate OrthancFramework/Sources/JobsEngine/SetOfCommandsJob.h @ 4733:1db3b79d97bd
Error code and description of jobs are now saved into the Orthanc database
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 28 Jun 2021 14:25:37 +0200 |
parents | d9473bd5ed43 |
children | 0a38000b086d |
rev | line source |
---|---|
2860 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4304
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
2860 | 6 * |
7 * 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:
4063
diff
changeset
|
8 * 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:
4063
diff
changeset
|
9 * 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:
4063
diff
changeset
|
10 * the License, or (at your option) any later version. |
2860 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * 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:
4063
diff
changeset
|
15 * Lesser General Public License for more details. |
2860 | 16 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
17 * 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:
4063
diff
changeset
|
18 * 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:
4063
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
2860 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
25 #include "IJob.h" | |
26 | |
4202
2007ab69ac16
moving ORTHANC_FORCE_INLINE and ORTHANC_OVERRIDE from Enumerations.h to Compatibility.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
27 #include "../Compatibility.h" // For ORTHANC_OVERRIDE |
2007ab69ac16
moving ORTHANC_FORCE_INLINE and ORTHANC_OVERRIDE from Enumerations.h to Compatibility.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
28 |
2860 | 29 #include <set> |
30 | |
31 namespace Orthanc | |
32 { | |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
33 class ORTHANC_PUBLIC SetOfCommandsJob : public IJob |
2860 | 34 { |
35 public: | |
36 class ICommand : public boost::noncopyable | |
37 { | |
38 public: | |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
39 virtual ~ICommand() |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
40 { |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
41 } |
2860 | 42 |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
43 virtual bool Execute(const std::string& jobId) = 0; |
2860 | 44 |
45 virtual void Serialize(Json::Value& target) const = 0; | |
46 }; | |
47 | |
48 class ICommandUnserializer : public boost::noncopyable | |
49 { | |
50 public: | |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
51 virtual ~ICommandUnserializer() |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
52 { |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
53 } |
2860 | 54 |
55 virtual ICommand* Unserialize(const Json::Value& source) const = 0; | |
56 }; | |
57 | |
58 private: | |
59 bool started_; | |
60 std::vector<ICommand*> commands_; | |
61 bool permissive_; | |
62 size_t position_; | |
63 std::string description_; | |
64 | |
65 public: | |
66 SetOfCommandsJob(); | |
67 | |
68 SetOfCommandsJob(ICommandUnserializer* unserializer /* takes ownership */, | |
69 const Json::Value& source); | |
70 | |
71 virtual ~SetOfCommandsJob(); | |
72 | |
4300 | 73 size_t GetPosition() const; |
2860 | 74 |
4300 | 75 void SetDescription(const std::string& description); |
2860 | 76 |
4304 | 77 const std::string& GetDescription() const; |
2860 | 78 |
79 void Reserve(size_t size); | |
80 | |
4300 | 81 size_t GetCommandsCount() const; |
2860 | 82 |
83 void AddCommand(ICommand* command); // Takes ownership | |
84 | |
4300 | 85 bool IsPermissive() const; |
2860 | 86 |
87 void SetPermissive(bool permissive); | |
88 | |
3674
9201a7858cce
fix warnings with recent wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
89 virtual void Reset() ORTHANC_OVERRIDE; |
2860 | 90 |
4300 | 91 virtual void Start() ORTHANC_OVERRIDE; |
2860 | 92 |
3674
9201a7858cce
fix warnings with recent wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
93 virtual float GetProgress() ORTHANC_OVERRIDE; |
2860 | 94 |
4300 | 95 bool IsStarted() const; |
2860 | 96 |
97 const ICommand& GetCommand(size_t index) const; | |
98 | |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
99 virtual JobStepResult Step(const std::string& jobId) ORTHANC_OVERRIDE; |
2860 | 100 |
3674
9201a7858cce
fix warnings with recent wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
101 virtual void GetPublicContent(Json::Value& value) ORTHANC_OVERRIDE; |
2860 | 102 |
3674
9201a7858cce
fix warnings with recent wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3658
diff
changeset
|
103 virtual bool Serialize(Json::Value& target) ORTHANC_OVERRIDE; |
2976
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2860
diff
changeset
|
104 |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2860
diff
changeset
|
105 virtual bool GetOutput(std::string& output, |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2860
diff
changeset
|
106 MimeType& mime, |
4300 | 107 const std::string& key) ORTHANC_OVERRIDE; |
2860 | 108 }; |
109 } |