Mercurial > hg > orthanc-wsi
comparison ViewerPlugin/DicomPyramidCache.h @ 73:a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 28 Nov 2016 16:51:19 +0100 |
parents | |
children | ff0ef01c332c |
comparison
equal
deleted
inserted
replaced
72:ea6309f70f1f | 73:a8c90aa32ca6 |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * | |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU Affero General Public License | |
8 * as published by the Free Software Foundation, either version 3 of | |
9 * the License, or (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, but | |
12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * Affero General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Affero General Public License | |
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 **/ | |
19 | |
20 | |
21 #pragma once | |
22 | |
23 #include "../Framework/Inputs/DicomPyramid.h" | |
24 #include "../Resources/Orthanc/Core/Cache/LeastRecentlyUsedIndex.h" | |
25 | |
26 #include <boost/thread/mutex.hpp> | |
27 | |
28 namespace OrthancWSI | |
29 { | |
30 class DicomPyramidCache : public boost::noncopyable | |
31 { | |
32 private: | |
33 typedef Orthanc::LeastRecentlyUsedIndex<std::string, DicomPyramid*> Cache; | |
34 | |
35 boost::mutex mutex_; | |
36 OrthancPlugins::IOrthancConnection& orthanc_; | |
37 size_t maxSize_; | |
38 Cache cache_; | |
39 | |
40 | |
41 DicomPyramid* GetCachedPyramid(const std::string& seriesId); | |
42 | |
43 DicomPyramid& GetPyramid(const std::string& seriesId, | |
44 boost::mutex::scoped_lock& lock); | |
45 | |
46 public: | |
47 DicomPyramidCache(OrthancPlugins::IOrthancConnection& orthanc, | |
48 size_t maxSize); | |
49 | |
50 ~DicomPyramidCache(); | |
51 | |
52 void Invalidate(const std::string& seriesId); | |
53 | |
54 class Locker : public boost::noncopyable | |
55 { | |
56 private: | |
57 boost::mutex::scoped_lock lock_; | |
58 DicomPyramid& pyramid_; | |
59 | |
60 public: | |
61 Locker(DicomPyramidCache& cache, | |
62 const std::string& seriesId); | |
63 | |
64 DicomPyramid& GetPyramid() const | |
65 { | |
66 return pyramid_; | |
67 } | |
68 }; | |
69 }; | |
70 } |