annotate Core/Cache/SharedArchive.h @ 1765:57b9e6890482

New configuration option: "Dictionary" to declare custom DICOM tags
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Oct 2015 16:49:25 +0100
parents b22ba8c5edbe
children b1291df2f780
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1367
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * In addition, as a special exception, the copyright holders of this
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * program give permission to link the code of its release with the
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * the linked executables. You must obey the GNU General Public License
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * you do not wish to do so, delete this exception statement from your
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * version. If you delete this exception statement from all source files
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * in the program, then also delete it here.
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #pragma once
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "LeastRecentlyUsedIndex.h"
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "../IDynamicObject.h"
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include <map>
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 #include <boost/thread.hpp>
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 namespace Orthanc
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 class SharedArchive : public boost::noncopyable
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 private:
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 typedef std::map<std::string, IDynamicObject*> Archive;
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 size_t maxSize_;
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 boost::mutex mutex_;
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 Archive archive_;
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 Orthanc::LeastRecentlyUsedIndex<std::string> lru_;
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 void RemoveInternal(const std::string& id);
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 public:
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 class Accessor : public boost::noncopyable
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 {
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 private:
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 boost::mutex::scoped_lock lock_;
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 IDynamicObject* item_;
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 public:
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 Accessor(SharedArchive& that,
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 const std::string& id);
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 IDynamicObject& GetItem() const
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 {
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 return *item_;
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 }
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 };
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1367
diff changeset
73 SharedArchive(size_t maxSize);
1367
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 ~SharedArchive();
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 std::string Add(IDynamicObject* obj); // Takes the ownership
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 void Remove(const std::string& id);
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 void List(std::list<std::string>& items);
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 };
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 }
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
fe6e5a9f1ea2 SharedArchive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85