annotate Framework/Loaders/BasicFetchingStrategy.h @ 879:12b591d5d63c am-dev

some Qt integration (wip)
author Alain Mazy <alain@mazy.be>
date Fri, 05 Jul 2019 14:52:43 +0200
parents 51976977d2d3
children 2d8ab34c8c91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
708
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #pragma once
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "IFetchingItemsSorter.h"
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "IFetchingStrategy.h"
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include <memory>
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 namespace OrthancStone
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 class BasicFetchingStrategy : public IFetchingStrategy
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 private:
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 class ContentItem
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 private:
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 unsigned int item_;
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 unsigned int quality_;
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 public:
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 ContentItem(unsigned int item,
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 unsigned int quality) :
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 item_(item),
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 quality_(quality)
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 }
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 unsigned int GetItem() const
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 {
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 return item_;
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 }
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 unsigned int GetQuality() const
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 {
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 return quality_;
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 }
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 };
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 std::auto_ptr<IFetchingItemsSorter> sorter_;
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 std::vector<unsigned int> nextQuality_;
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 unsigned int maxQuality_;
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 std::vector<ContentItem> content_;
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 size_t position_;
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 unsigned int blockSize_;
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 void Schedule(unsigned int item,
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 unsigned int quality);
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 public:
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 BasicFetchingStrategy(IFetchingItemsSorter* sorter, // Takes ownership
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 unsigned int maxQuality);
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 virtual unsigned int GetItemsCount() const
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 {
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 return sorter_->GetItemsCount();
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 }
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 virtual unsigned int GetMaxQuality() const
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 {
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 return maxQuality_;
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 }
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 // WARNING - This parameters is only considered during the next
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 // call to SetCurrent().
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 void SetBlockSize(unsigned int size);
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 virtual bool GetNext(unsigned int& item,
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 unsigned int& quality);
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 virtual void SetCurrent(unsigned int item);
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 virtual void RecycleFurthest(unsigned int& item);
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 };
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }