comparison Plugins/Samples/StorageCommitmentScp/Plugin.cpp @ 3664:85acfcc15829 storage-commitment

sample storage commitment plugin, C++ wrapper
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Feb 2020 16:06:58 +0100
parents
children 4c1d2ff7ddd0
comparison
equal deleted inserted replaced
3662:d8371b4302ff 3664:85acfcc15829
1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
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
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21
22 #include "../Common/OrthancPluginCppWrapper.h"
23
24 #include <json/value.h>
25 #include <json/reader.h>
26
27
28
29 class StorageCommitmentSample : public OrthancPlugins::IStorageCommitmentScpHandler
30 {
31 private:
32 int count_;
33
34 public:
35 StorageCommitmentSample() : count_(0)
36 {
37 }
38
39 virtual OrthancPluginStorageCommitmentFailureReason Lookup(const std::string& sopClassUid,
40 const std::string& sopInstanceUid)
41 {
42 printf("?? [%s] [%s]\n", sopClassUid.c_str(), sopInstanceUid.c_str());
43 if (count_++ % 2 == 0)
44 return OrthancPluginStorageCommitmentFailureReason_Success;
45 else
46 return OrthancPluginStorageCommitmentFailureReason_NoSuchObjectInstance;
47 }
48 };
49
50
51 static void* StorageCommitmentScp(const char* jobId,
52 const char* transactionUid,
53 const char* const* sopClassUids,
54 const char* const* sopInstanceUids,
55 uint32_t countInstances,
56 const char* remoteAet,
57 const char* calledAet)
58 {
59 printf("[%s] [%s] [%s] [%s]\n", jobId, transactionUid, remoteAet, calledAet);
60
61 for (uint32_t i = 0; i < countInstances; i++)
62 {
63 printf("++ [%s] [%s]\n", sopClassUids[i], sopInstanceUids[i]);
64 }
65
66 return new StorageCommitmentSample;
67 }
68
69
70 extern "C"
71 {
72 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c)
73 {
74 OrthancPlugins::SetGlobalContext(c);
75
76 /* Check the version of the Orthanc core */
77 if (OrthancPluginCheckVersion(c) == 0)
78 {
79 OrthancPlugins::ReportMinimalOrthancVersion(ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
80 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
81 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
82 return -1;
83 }
84
85 OrthancPluginSetDescription(c, "Sample storage commitment SCP plugin.");
86
87 OrthancPluginRegisterStorageCommitmentScpCallback(c, StorageCommitmentScp,
88 OrthancPlugins::IStorageCommitmentScpHandler::Destructor,
89 OrthancPlugins::IStorageCommitmentScpHandler::Lookup);
90
91 return 0;
92 }
93
94
95 ORTHANC_PLUGINS_API void OrthancPluginFinalize()
96 {
97 }
98
99
100 ORTHANC_PLUGINS_API const char* OrthancPluginGetName()
101 {
102 return "storage-commitment-scp";
103 }
104
105
106 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion()
107 {
108 return PLUGIN_VERSION;
109 }
110 }