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 "DicomInstanceInfo.h"
|
|
23 #include "TransferToolbox.h"
|
|
24
|
|
25 namespace OrthancPlugins
|
|
26 {
|
|
27 class TransferBucket
|
|
28 {
|
|
29 private:
|
|
30 struct Chunk
|
|
31 {
|
|
32 std::string instanceId_;
|
|
33 size_t offset_;
|
|
34 size_t size_;
|
|
35 };
|
|
36
|
|
37 std::vector<Chunk> chunks_;
|
|
38 size_t totalSize_;
|
|
39 bool extensible_;
|
|
40
|
|
41 public:
|
|
42 TransferBucket();
|
|
43
|
|
44 TransferBucket(const Json::Value& serialized);
|
|
45
|
|
46 size_t GetTotalSize() const
|
|
47 {
|
|
48 return totalSize_;
|
|
49 }
|
|
50
|
|
51 void Reserve(size_t size)
|
|
52 {
|
|
53 chunks_.reserve(size);
|
|
54 }
|
|
55
|
|
56 size_t GetChunksCount() const
|
|
57 {
|
|
58 return chunks_.size();
|
|
59 }
|
|
60
|
|
61 void Serialize(Json::Value& target) const;
|
|
62
|
|
63 void Clear();
|
|
64
|
|
65 void AddChunk(const DicomInstanceInfo& instance,
|
|
66 size_t chunkOffset,
|
|
67 size_t chunkSize);
|
|
68
|
|
69 const std::string& GetChunkInstanceId(size_t index) const;
|
|
70
|
|
71 size_t GetChunkOffset(size_t index) const;
|
|
72
|
|
73 size_t GetChunkSize(size_t index) const;
|
|
74
|
|
75 void ComputePullUri(std::string& uri,
|
|
76 BucketCompression compression) const;
|
|
77 };
|
|
78 }
|