comparison Plugin/ResourceHierarchyCache.h @ 1:d5d3cb00556a

initial release
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 22 Mar 2017 16:13:52 +0100
parents
children bc0431cb6b8f
comparison
equal deleted inserted replaced
0:decac5df19c4 1:d5d3cb00556a
1 /**
2 * Advanced authorization plugin for Orthanc
3 * Copyright (C) 2017 Osimis, Belgium
4 *
5 * This program is free software: you can redistribute it and/or
6 * modify it under the terms of the GNU Affero General Public License
7 * as published by the Free Software Foundation, either version 3 of
8 * the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 **/
18
19 #pragma once
20
21 #include "ICacheFactory.h"
22 #include "Enumerations.h"
23 #include "OrthancResource.h"
24
25 #include <orthanc/OrthancCPlugin.h>
26 #include <memory>
27
28 namespace OrthancPlugins
29 {
30 class ResourceHierarchyCache : public boost::noncopyable
31 {
32 private:
33 OrthancPluginContext *context_;
34 std::auto_ptr<ICache> cache_; // Maps resources to their parents
35 std::auto_ptr<ICache> orthancToDicom_;
36 std::auto_ptr<ICache> dicomToOrthanc_;
37
38 std::string ComputeKey(Orthanc::ResourceType level,
39 const std::string identifier) const;
40
41 std::string ComputeKey(const OrthancResource& resource) const
42 {
43 return ComputeKey(resource.GetLevel(), resource.GetIdentifier());
44 }
45
46 void LinkParent(const OrthancResource& child,
47 const OrthancResource& parent);
48
49 bool LookupParent(std::string& target,
50 const OrthancResource& resource);
51
52 bool LookupParent(std::string& target,
53 Orthanc::ResourceType level,
54 const std::string& identifier)
55 {
56 return LookupParent(target, OrthancResource(level, identifier));
57 }
58
59 public:
60 ResourceHierarchyCache(OrthancPluginContext* context,
61 ICacheFactory& factory);
62
63 void Invalidate(Orthanc::ResourceType level,
64 const std::string& identifier);
65
66 bool LookupStudy(std::string& patient,
67 const std::string& study)
68 {
69 return LookupParent(patient, Orthanc::ResourceType_Study, study);
70 }
71
72 bool LookupSeries(std::string& patient,
73 std::string& study,
74 const std::string& series);
75
76 bool LookupInstance(std::string& patient,
77 std::string& study,
78 std::string& series,
79 const std::string& instance);
80
81 bool LookupDicomUid(std::string& target,
82 Orthanc::ResourceType level,
83 const std::string& orthancId);
84
85 bool LookupOrthancId(std::string& target,
86 Orthanc::ResourceType level,
87 const std::string& dicomUid);
88 };
89 }