Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Loaders/BasicFetchingStrategy.h @ 2129:169e2e586ef7 StoneWebViewer-2.2
closing StoneWebViewer-2.2
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 30 May 2024 17:08:21 +0200 |
parents | 1a775f4ee672 |
children | 3889ae96d2e9 |
rev | line source |
---|---|
708 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
708 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
708 | 9 * as published by the Free Software Foundation, either version 3 of |
10 * the 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 | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
708 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
25 #include "IFetchingItemsSorter.h" | |
26 #include "IFetchingStrategy.h" | |
27 | |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1298
diff
changeset
|
28 #include <Compatibility.h> |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
29 |
708 | 30 #include <memory> |
31 | |
32 namespace OrthancStone | |
33 { | |
34 class BasicFetchingStrategy : public IFetchingStrategy | |
35 { | |
36 private: | |
37 class ContentItem | |
38 { | |
39 private: | |
40 unsigned int item_; | |
41 unsigned int quality_; | |
42 | |
43 public: | |
44 ContentItem(unsigned int item, | |
45 unsigned int quality) : | |
46 item_(item), | |
47 quality_(quality) | |
48 { | |
49 } | |
50 | |
51 unsigned int GetItem() const | |
52 { | |
53 return item_; | |
54 } | |
55 | |
56 unsigned int GetQuality() const | |
57 { | |
58 return quality_; | |
59 } | |
60 }; | |
61 | |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
62 std::unique_ptr<IFetchingItemsSorter> sorter_; |
708 | 63 std::vector<unsigned int> nextQuality_; |
64 unsigned int maxQuality_; | |
65 std::vector<ContentItem> content_; | |
66 size_t position_; | |
67 unsigned int blockSize_; | |
68 | |
69 void Schedule(unsigned int item, | |
70 unsigned int quality); | |
71 | |
72 public: | |
73 BasicFetchingStrategy(IFetchingItemsSorter* sorter, // Takes ownership | |
1755
1a775f4ee672
added ability to specify initial slice in
bgo@SHARKNADO.localdomain
parents:
1739
diff
changeset
|
74 unsigned int maxQuality, |
1a775f4ee672
added ability to specify initial slice in
bgo@SHARKNADO.localdomain
parents:
1739
diff
changeset
|
75 unsigned int initialItem = 0); |
708 | 76 |
1571 | 77 virtual unsigned int GetItemsCount() const ORTHANC_OVERRIDE |
708 | 78 { |
79 return sorter_->GetItemsCount(); | |
80 } | |
81 | |
1571 | 82 virtual unsigned int GetMaxQuality() const ORTHANC_OVERRIDE |
708 | 83 { |
84 return maxQuality_; | |
85 } | |
86 | |
87 // WARNING - This parameters is only considered during the next | |
88 // call to SetCurrent(). | |
89 void SetBlockSize(unsigned int size); | |
90 | |
91 virtual bool GetNext(unsigned int& item, | |
1571 | 92 unsigned int& quality) ORTHANC_OVERRIDE; |
708 | 93 |
1571 | 94 virtual void SetCurrent(unsigned int item) ORTHANC_OVERRIDE; |
708 | 95 |
1571 | 96 virtual void RecycleFurthest(unsigned int& item) ORTHANC_OVERRIDE; |
708 | 97 }; |
98 } |