annotate Plugin/PluginContext.h @ 62:bb2842b670d1

fix windows resources
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 08 Sep 2023 14:27:17 +0200
parents b09adb6aa199
children 1e396fb509ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Transfers accelerator plugin for Orthanc
33
44a0430d7899 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 25
diff changeset
3 * Copyright (C) 2018-2021 Osimis S.A., Belgium
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 *
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * modify it under the terms of the GNU Affero General Public License
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * as published by the Free Software Foundation, either version 3 of
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * the License, or (at your option) any later version.
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 *
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful, but
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * Affero General Public License for more details.
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 *
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU Affero General Public License
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 **/
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 #pragma once
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "../Framework/OrthancInstancesCache.h"
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "../Framework/PushMode/ActivePushTransactions.h"
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
25
dfc43678aecb replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
25 #include <Compatibility.h> // For std::unique_ptr
20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
26 #include <MultiThreading/Semaphore.h>
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include <map>
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 namespace OrthancPlugins
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 class PluginContext : public boost::noncopyable
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 private:
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 // Runtime structures
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 OrthancInstancesCache cache_;
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 ActivePushTransactions pushTransactions_;
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 Orthanc::Semaphore semaphore_;
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 std::string pluginUuid_;
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 // Configuration
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 size_t threadsCount_;
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 size_t targetBucketSize_;
10
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
44 unsigned int maxHttpRetries_;
55
b09adb6aa199 new PeerConnectivityTimeout configuration
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
45 unsigned int peerConnectivityTimeout_;
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
8
4c3437217518 fix for compatibility with simplified OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5
diff changeset
47 PluginContext(size_t threadsCount,
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 size_t targetBucketSize,
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 size_t maxPushTransactions,
10
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
50 size_t memoryCacheSize,
55
b09adb6aa199 new PeerConnectivityTimeout configuration
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
51 unsigned int maxHttpRetries,
b09adb6aa199 new PeerConnectivityTimeout configuration
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
52 unsigned int peerConnectivityTimeout);
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
25
dfc43678aecb replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
54 static std::unique_ptr<PluginContext>& GetSingleton();
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 public:
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 OrthancInstancesCache& GetCache()
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 return cache_;
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 ActivePushTransactions& GetActivePushTransactions()
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 return pushTransactions_;
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 Orthanc::Semaphore& GetSemaphore()
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 return semaphore_;
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 const std::string& GetPluginUuid() const
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 return pluginUuid_;
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 size_t GetThreadsCount() const
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 return threadsCount_;
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 size_t GetTargetBucketSize() const
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 return targetBucketSize_;
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
10
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
87 unsigned int GetMaxHttpRetries() const
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
88 {
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
89 return maxHttpRetries_;
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
90 }
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
91
55
b09adb6aa199 new PeerConnectivityTimeout configuration
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
92 unsigned int GetPeerConnectivityTimeout() const
b09adb6aa199 new PeerConnectivityTimeout configuration
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
93 {
b09adb6aa199 new PeerConnectivityTimeout configuration
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
94 return peerConnectivityTimeout_;
b09adb6aa199 new PeerConnectivityTimeout configuration
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
95 }
b09adb6aa199 new PeerConnectivityTimeout configuration
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
96
8
4c3437217518 fix for compatibility with simplified OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5
diff changeset
97 static void Initialize(size_t threadsCount,
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 size_t targetBucketSize,
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 size_t maxPushTransactions,
10
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
100 size_t memoryCacheSize,
55
b09adb6aa199 new PeerConnectivityTimeout configuration
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
101 unsigned int maxHttpRetries,
b09adb6aa199 new PeerConnectivityTimeout configuration
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
102 unsigned int peerConnectivityTimeout);
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 static PluginContext& GetInstance();
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 static void Finalize();
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 };
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 }