0
|
1 /**
|
|
2 * Transfers accelerator plugin for Orthanc
|
|
3 * Copyright (C) 2018 Osimis, Belgium
|
|
4 *
|
|
5 * This program is free software: you can redistribute it and/or
|
|
6 * modify it under the terms of the GNU Affero General Public License
|
|
7 * as published by the Free Software Foundation, either version 3 of
|
|
8 * the License, or (at your option) any later version.
|
|
9 *
|
|
10 * This program is distributed in the hope that it will be useful, but
|
|
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13 * Affero General Public License for more details.
|
|
14 *
|
|
15 * You should have received a copy of the GNU Affero General Public License
|
|
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17 **/
|
|
18
|
|
19
|
|
20 #pragma once
|
|
21
|
|
22 #include "../Framework/OrthancInstancesCache.h"
|
|
23 #include "../Framework/PushMode/ActivePushTransactions.h"
|
|
24
|
|
25 #include <Core/MultiThreading/Semaphore.h>
|
|
26
|
|
27 #include <map>
|
|
28
|
|
29 namespace OrthancPlugins
|
|
30 {
|
|
31 class PluginContext : public boost::noncopyable
|
|
32 {
|
|
33 private:
|
|
34 typedef std::map<std::string, std::string> BidirectionalPeers;
|
|
35
|
|
36 // Runtime structures
|
|
37 OrthancPluginContext* context_;
|
|
38 OrthancInstancesCache cache_;
|
|
39 ActivePushTransactions pushTransactions_;
|
|
40 Orthanc::Semaphore semaphore_;
|
|
41 std::string pluginUuid_;
|
|
42
|
|
43 // Configuration
|
|
44 size_t threadsCount_;
|
|
45 size_t targetBucketSize_;
|
|
46 BidirectionalPeers bidirectionalPeers_;
|
|
47
|
|
48
|
|
49 PluginContext(OrthancPluginContext* context,
|
|
50 size_t threadsCount,
|
|
51 size_t targetBucketSize,
|
|
52 size_t maxPushTransactions,
|
|
53 size_t memoryCacheSize);
|
|
54
|
|
55 static std::auto_ptr<PluginContext>& GetSingleton();
|
|
56
|
|
57 public:
|
|
58 OrthancPluginContext* GetOrthanc()
|
|
59 {
|
|
60 return context_;
|
|
61 }
|
|
62
|
|
63 OrthancInstancesCache& GetCache()
|
|
64 {
|
|
65 return cache_;
|
|
66 }
|
|
67
|
|
68 ActivePushTransactions& GetActivePushTransactions()
|
|
69 {
|
|
70 return pushTransactions_;
|
|
71 }
|
|
72
|
|
73 Orthanc::Semaphore& GetSemaphore()
|
|
74 {
|
|
75 return semaphore_;
|
|
76 }
|
|
77
|
|
78 const std::string& GetPluginUuid() const
|
|
79 {
|
|
80 return pluginUuid_;
|
|
81 }
|
|
82
|
|
83 size_t GetThreadsCount() const
|
|
84 {
|
|
85 return threadsCount_;
|
|
86 }
|
|
87
|
|
88 size_t GetTargetBucketSize() const
|
|
89 {
|
|
90 return targetBucketSize_;
|
|
91 }
|
|
92
|
|
93 void AddBidirectionalPeer(const std::string& remotePeer,
|
|
94 const std::string& remoteSelf)
|
|
95 {
|
|
96 bidirectionalPeers_[remotePeer] = remoteSelf;
|
|
97 }
|
|
98
|
|
99 void LoadBidirectionalPeers(const BidirectionalPeers& peers)
|
|
100 {
|
|
101 bidirectionalPeers_ = peers;
|
|
102 }
|
|
103
|
|
104 bool LookupBidirectionalPeer(std::string& remoteSelf,
|
|
105 const std::string& remotePeer) const;
|
|
106
|
|
107 static void Initialize(OrthancPluginContext* context,
|
|
108 size_t threadsCount,
|
|
109 size_t targetBucketSize,
|
|
110 size_t maxPushTransactions,
|
|
111 size_t memoryCacheSize);
|
|
112
|
|
113 static PluginContext& GetInstance();
|
|
114
|
|
115 static void Finalize();
|
|
116 };
|
|
117 }
|