Mercurial > hg > orthanc
annotate OrthancFramework/Sources/Cache/SharedArchive.h @ 5474:6cb91df32207 Orthanc-1.12.2
Orthanc-1.12.2
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 19 Dec 2023 10:05:57 +0100 |
parents | b5c502bcaf99 |
children | 48b8dae6dc77 |
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 |
5185
0ea402b4d901
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
0ea402b4d901
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1367 | 7 * |
8 * 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
|
9 * 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
|
10 * 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
|
11 * the License, or (at your option) any later version. |
1367 | 12 * |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * 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
|
16 * Lesser General Public License for more details. |
1367 | 17 * |
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
|
18 * 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
|
19 * 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
|
20 * <http://www.gnu.org/licenses/>. |
1367 | 21 **/ |
22 | |
23 | |
24 #pragma once | |
25 | |
2407
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
26 #if !defined(ORTHANC_SANDBOXED) |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
27 # error The macro ORTHANC_SANDBOXED must be defined |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
28 #endif |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
29 |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
30 #if ORTHANC_SANDBOXED == 1 |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
31 # error The class SharedArchive cannot be used in sandboxed environments |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
32 #endif |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
33 |
1367 | 34 #include "LeastRecentlyUsedIndex.h" |
35 #include "../IDynamicObject.h" | |
36 | |
37 #include <map> | |
38 #include <boost/thread.hpp> | |
39 | |
40 namespace Orthanc | |
41 { | |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
42 class ORTHANC_PUBLIC SharedArchive : public boost::noncopyable |
1367 | 43 { |
44 private: | |
45 typedef std::map<std::string, IDynamicObject*> Archive; | |
46 | |
5310
b5c502bcaf99
added a route to DELETE /jobs/../archive
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
47 size_t maxSize_; |
b5c502bcaf99
added a route to DELETE /jobs/../archive
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
48 boost::recursive_mutex mutex_; |
b5c502bcaf99
added a route to DELETE /jobs/../archive
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
49 Archive archive_; |
3557
4d809b2e1141
better cache toolbox: MemoryObjectCache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
50 LeastRecentlyUsedIndex<std::string> lru_; |
1367 | 51 |
52 void RemoveInternal(const std::string& id); | |
53 | |
54 public: | |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
55 class ORTHANC_PUBLIC Accessor : public boost::noncopyable |
1367 | 56 { |
57 private: | |
5310
b5c502bcaf99
added a route to DELETE /jobs/../archive
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
58 boost::recursive_mutex::scoped_lock lock_; |
b5c502bcaf99
added a route to DELETE /jobs/../archive
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
59 IDynamicObject* item_; |
1367 | 60 |
61 public: | |
62 Accessor(SharedArchive& that, | |
63 const std::string& id); | |
64 | |
4300 | 65 bool IsValid() const; |
2976
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
66 |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
67 IDynamicObject& GetItem() const; |
1367 | 68 }; |
69 | |
70 | |
4199 | 71 explicit SharedArchive(size_t maxSize); |
1367 | 72 |
73 ~SharedArchive(); | |
74 | |
75 std::string Add(IDynamicObject* obj); // Takes the ownership | |
76 | |
77 void Remove(const std::string& id); | |
78 | |
79 void List(std::list<std::string>& items); | |
80 }; | |
81 } | |
82 | |
83 |