annotate OrthancFramework/Sources/JobsEngine/SetOfCommandsJob.h @ 4845:02d77189d8ba received-instance-callback

added ReceivedInstanceCallback + sample C++ plugin
author Alain Mazy <am@osimis.io>
date Thu, 09 Dec 2021 17:22:40 +0100
parents 7053502fbf97
children 43e613a7756b
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
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
4831
7053502fbf97 added copyright UCLouvain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4805
diff changeset
6 * Copyright (C) 2021-2021 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * 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
9 * 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
10 * 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
11 * the License, or (at your option) any later version.
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * 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
16 * Lesser General Public License for more details.
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
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
18 * 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
19 * 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
20 * <http://www.gnu.org/licenses/>.
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "IJob.h"
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
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
28 #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
29
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include <set>
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 namespace Orthanc
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
34 class ORTHANC_PUBLIC SetOfCommandsJob : public IJob
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 public:
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 class ICommand : public boost::noncopyable
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 public:
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
40 virtual ~ICommand()
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
41 {
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
42 }
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
3658
2d90dd30858c providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
44 virtual bool Execute(const std::string& jobId) = 0;
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 virtual void Serialize(Json::Value& target) const = 0;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 };
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 class ICommandUnserializer : public boost::noncopyable
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 public:
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
52 virtual ~ICommandUnserializer()
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
53 {
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
54 }
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 virtual ICommand* Unserialize(const Json::Value& source) const = 0;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 };
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 private:
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 bool started_;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 std::vector<ICommand*> commands_;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 bool permissive_;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 size_t position_;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 std::string description_;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 public:
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 SetOfCommandsJob();
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 SetOfCommandsJob(ICommandUnserializer* unserializer /* takes ownership */,
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 const Json::Value& source);
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 virtual ~SetOfCommandsJob();
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4202
diff changeset
74 size_t GetPosition() const;
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4202
diff changeset
76 void SetDescription(const std::string& description);
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
4304
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4303
diff changeset
78 const std::string& GetDescription() const;
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 void Reserve(size_t size);
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4202
diff changeset
82 size_t GetCommandsCount() const;
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 void AddCommand(ICommand* command); // Takes ownership
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4202
diff changeset
86 bool IsPermissive() const;
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 void SetPermissive(bool permissive);
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
3674
9201a7858cce fix warnings with recent wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3658
diff changeset
90 virtual void Reset() ORTHANC_OVERRIDE;
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4202
diff changeset
92 virtual void Start() ORTHANC_OVERRIDE;
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93
3674
9201a7858cce fix warnings with recent wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3658
diff changeset
94 virtual float GetProgress() ORTHANC_OVERRIDE;
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4202
diff changeset
96 bool IsStarted() const;
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 const ICommand& GetCommand(size_t index) const;
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
3658
2d90dd30858c providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
100 virtual JobStepResult Step(const std::string& jobId) ORTHANC_OVERRIDE;
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
3674
9201a7858cce fix warnings with recent wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3658
diff changeset
102 virtual void GetPublicContent(Json::Value& value) ORTHANC_OVERRIDE;
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
3674
9201a7858cce fix warnings with recent wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3658
diff changeset
104 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
105
cb5d75143da0 Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2860
diff changeset
106 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
107 MimeType& mime,
4805
0a38000b086d Archive jobs response now contains a header Content-Disposition:filename='archive.zip'
Alain Mazy <am@osimis.io>
parents: 4437
diff changeset
108 std::string& filename,
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4202
diff changeset
109 const std::string& key) ORTHANC_OVERRIDE;
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 };
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 }