comparison Framework/PushMode/ActivePushTransactions.h @ 0:95226b754d9e

initial release
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 17 Sep 2018 11:34:55 +0200
parents
children 4c3437217518
comparison
equal deleted inserted replaced
-1:000000000000 0:95226b754d9e
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 "../TransferBucket.h"
23
24 #include <orthanc/OrthancCPlugin.h>
25 #include <Core/Cache/LeastRecentlyUsedIndex.h>
26
27 #include <boost/thread/mutex.hpp>
28
29 namespace OrthancPlugins
30 {
31 class ActivePushTransactions : public boost::noncopyable
32 {
33 private:
34 class Transaction;
35
36 typedef Orthanc::LeastRecentlyUsedIndex<std::string> Index;
37 typedef std::map<std::string, Transaction*> Content;
38
39 boost::mutex mutex_;
40 Content content_;
41 Index index_;
42 size_t maxSize_;
43
44 void FinalizeTransaction(OrthancPluginContext* context,
45 const std::string& transactionUuid,
46 bool commit);
47
48 public:
49 ActivePushTransactions(size_t maxSize) :
50 maxSize_(maxSize)
51 {
52 }
53
54 ~ActivePushTransactions();
55
56 void ListTransactions(std::vector<std::string>& target);
57
58 std::string CreateTransaction(const std::vector<DicomInstanceInfo>& instances,
59 const std::vector<TransferBucket>& buckets,
60 BucketCompression compression);
61
62 void Store(OrthancPluginContext* context,
63 const std::string& transactionUuid,
64 size_t bucketIndex,
65 const void* data,
66 size_t size);
67
68 void Commit(OrthancPluginContext* context,
69 const std::string& transactionUuid)
70 {
71 FinalizeTransaction(context, transactionUuid, true);
72 }
73
74 void Discard(const std::string& transactionUuid)
75 {
76 FinalizeTransaction(NULL, transactionUuid, false);
77 }
78 };
79 }