annotate OrthancServer/Plugins/Samples/StorageCommitmentScp/Plugin.cpp @ 4831:7053502fbf97

added copyright UCLouvain
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 25 Nov 2021 19:01:11 +0100
parents d9473bd5ed43
children 43e613a7756b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3664
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
85acfcc15829 sample storage commitment plugin, C++ wrapper
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: 4395
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
4831
7053502fbf97 added copyright UCLouvain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
6 * Copyright (C) 2021-2021 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
3664
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * General Public License for more details.
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "../Common/OrthancPluginCppWrapper.h"
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include <json/value.h>
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 class StorageCommitmentSample : public OrthancPlugins::IStorageCommitmentScpHandler
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 private:
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 int count_;
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 public:
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 StorageCommitmentSample() : count_(0)
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 }
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 virtual OrthancPluginStorageCommitmentFailureReason Lookup(const std::string& sopClassUid,
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 const std::string& sopInstanceUid)
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 printf("?? [%s] [%s]\n", sopClassUid.c_str(), sopInstanceUid.c_str());
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 if (count_++ % 2 == 0)
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 return OrthancPluginStorageCommitmentFailureReason_Success;
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 else
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 return OrthancPluginStorageCommitmentFailureReason_NoSuchObjectInstance;
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 }
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 };
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
3665
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
50 static OrthancPluginErrorCode StorageCommitmentScp(void** handler /* out */,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
51 const char* jobId,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
52 const char* transactionUid,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
53 const char* const* sopClassUids,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
54 const char* const* sopInstanceUids,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
55 uint32_t countInstances,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
56 const char* remoteAet,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
57 const char* calledAet)
3664
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
3675
340bdcc298e9 test pausing storage commitment plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3665
diff changeset
59 /*std::string s;
340bdcc298e9 test pausing storage commitment plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3665
diff changeset
60 OrthancPlugins::RestApiPost(s, "/jobs/" + std::string(jobId) + "/pause", NULL, 0, false);*/
340bdcc298e9 test pausing storage commitment plugin jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3665
diff changeset
61
3664
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 printf("[%s] [%s] [%s] [%s]\n", jobId, transactionUid, remoteAet, calledAet);
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 for (uint32_t i = 0; i < countInstances; i++)
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 printf("++ [%s] [%s]\n", sopClassUids[i], sopInstanceUids[i]);
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 }
3665
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
68
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
69 *handler = new StorageCommitmentSample;
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
70 return OrthancPluginErrorCode_Success;
3664
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 }
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 extern "C"
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c)
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 OrthancPlugins::SetGlobalContext(c);
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 /* Check the version of the Orthanc core */
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 if (OrthancPluginCheckVersion(c) == 0)
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 OrthancPlugins::ReportMinimalOrthancVersion(ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 return -1;
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 }
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 OrthancPluginSetDescription(c, "Sample storage commitment SCP plugin.");
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
3665
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
91 OrthancPluginRegisterStorageCommitmentScpCallback(
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
92 c, StorageCommitmentScp,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
93 OrthancPlugins::IStorageCommitmentScpHandler::Destructor,
4c1d2ff7ddd0 handling of errors in storage commitment plugin factory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3664
diff changeset
94 OrthancPlugins::IStorageCommitmentScpHandler::Lookup);
3664
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 return 0;
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 }
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 ORTHANC_PLUGINS_API void OrthancPluginFinalize()
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 ORTHANC_PLUGINS_API const char* OrthancPluginGetName()
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 return "storage-commitment-scp";
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 }
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion()
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 return PLUGIN_VERSION;
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 }
85acfcc15829 sample storage commitment plugin, C++ wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 }