Mercurial > hg > orthanc
annotate OrthancFramework/Sources/Cache/SharedArchive.h @ 4596:2b64cc3cea99
added OrthancPluginContentType_DicomUntilPixelData
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 17 Mar 2021 15:31:26 +0100 |
parents | d9473bd5ed43 |
children | 7053502fbf97 |
rev | line source |
---|---|
1367 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1367 | 4 * Department, University Hospital of Liege, Belgium |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
1367 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
10 * the License, or (at your option) any later version. |
1367 | 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 | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
15 * Lesser General Public License for more details. |
1367 | 16 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
18 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
1367 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
2407
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
25 #if !defined(ORTHANC_SANDBOXED) |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
26 # error The macro ORTHANC_SANDBOXED must be defined |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
27 #endif |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
28 |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
29 #if ORTHANC_SANDBOXED == 1 |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
30 # error The class SharedArchive cannot be used in sandboxed environments |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
31 #endif |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
32 |
1367 | 33 #include "LeastRecentlyUsedIndex.h" |
34 #include "../IDynamicObject.h" | |
35 | |
36 #include <map> | |
37 #include <boost/thread.hpp> | |
38 | |
39 namespace Orthanc | |
40 { | |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
41 class ORTHANC_PUBLIC SharedArchive : public boost::noncopyable |
1367 | 42 { |
43 private: | |
44 typedef std::map<std::string, IDynamicObject*> Archive; | |
45 | |
46 size_t maxSize_; | |
47 boost::mutex mutex_; | |
48 Archive archive_; | |
3557
4d809b2e1141
better cache toolbox: MemoryObjectCache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
49 LeastRecentlyUsedIndex<std::string> lru_; |
1367 | 50 |
51 void RemoveInternal(const std::string& id); | |
52 | |
53 public: | |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
54 class ORTHANC_PUBLIC Accessor : public boost::noncopyable |
1367 | 55 { |
56 private: | |
57 boost::mutex::scoped_lock lock_; | |
58 IDynamicObject* item_; | |
59 | |
60 public: | |
61 Accessor(SharedArchive& that, | |
62 const std::string& id); | |
63 | |
4300 | 64 bool IsValid() const; |
2976
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
65 |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
66 IDynamicObject& GetItem() const; |
1367 | 67 }; |
68 | |
69 | |
4199 | 70 explicit SharedArchive(size_t maxSize); |
1367 | 71 |
72 ~SharedArchive(); | |
73 | |
74 std::string Add(IDynamicObject* obj); // Takes the ownership | |
75 | |
76 void Remove(const std::string& id); | |
77 | |
78 void List(std::list<std::string>& items); | |
79 }; | |
80 } | |
81 | |
82 |