Mercurial > hg > orthanc-stone
comparison Framework/Loaders/BasicFetchingStrategy.h @ 708:51976977d2d3
reorganization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 20 May 2019 11:20:01 +0200 |
parents | |
children | 2d8ab34c8c91 |
comparison
equal
deleted
inserted
replaced
707:d1feb89ea742 | 708:51976977d2d3 |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
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 | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include "IFetchingItemsSorter.h" | |
25 #include "IFetchingStrategy.h" | |
26 | |
27 #include <memory> | |
28 | |
29 namespace OrthancStone | |
30 { | |
31 class BasicFetchingStrategy : public IFetchingStrategy | |
32 { | |
33 private: | |
34 class ContentItem | |
35 { | |
36 private: | |
37 unsigned int item_; | |
38 unsigned int quality_; | |
39 | |
40 public: | |
41 ContentItem(unsigned int item, | |
42 unsigned int quality) : | |
43 item_(item), | |
44 quality_(quality) | |
45 { | |
46 } | |
47 | |
48 unsigned int GetItem() const | |
49 { | |
50 return item_; | |
51 } | |
52 | |
53 unsigned int GetQuality() const | |
54 { | |
55 return quality_; | |
56 } | |
57 }; | |
58 | |
59 std::auto_ptr<IFetchingItemsSorter> sorter_; | |
60 std::vector<unsigned int> nextQuality_; | |
61 unsigned int maxQuality_; | |
62 std::vector<ContentItem> content_; | |
63 size_t position_; | |
64 unsigned int blockSize_; | |
65 | |
66 void Schedule(unsigned int item, | |
67 unsigned int quality); | |
68 | |
69 public: | |
70 BasicFetchingStrategy(IFetchingItemsSorter* sorter, // Takes ownership | |
71 unsigned int maxQuality); | |
72 | |
73 virtual unsigned int GetItemsCount() const | |
74 { | |
75 return sorter_->GetItemsCount(); | |
76 } | |
77 | |
78 virtual unsigned int GetMaxQuality() const | |
79 { | |
80 return maxQuality_; | |
81 } | |
82 | |
83 // WARNING - This parameters is only considered during the next | |
84 // call to SetCurrent(). | |
85 void SetBlockSize(unsigned int size); | |
86 | |
87 virtual bool GetNext(unsigned int& item, | |
88 unsigned int& quality); | |
89 | |
90 virtual void SetCurrent(unsigned int item); | |
91 | |
92 virtual void RecycleFurthest(unsigned int& item); | |
93 }; | |
94 } |