Mercurial > hg > orthanc-stl
comparison Sources/ResourcesCache.h @ 72:e94f177c3653
reorganization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 04 Oct 2024 17:25:46 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
71:f3bbafc067d0 | 72:e94f177c3653 |
---|---|
1 /** | |
2 * SPDX-FileCopyrightText: 2023-2024 Sebastien Jodogne, UCLouvain, Belgium | |
3 * SPDX-License-Identifier: GPL-3.0-or-later | |
4 */ | |
5 | |
6 /** | |
7 * STL plugin for Orthanc | |
8 * Copyright (C) 2023-2024 Sebastien Jodogne, UCLouvain, Belgium | |
9 * | |
10 * This program is free software: you can redistribute it and/or | |
11 * modify it under the terms of the GNU General Public License as | |
12 * published by the Free Software Foundation, either version 3 of the | |
13 * License, or (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, but | |
16 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 * General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
22 **/ | |
23 | |
24 | |
25 #pragma once | |
26 | |
27 #include <orthanc/OrthancCPlugin.h> | |
28 | |
29 #include <boost/noncopyable.hpp> | |
30 #include <boost/thread/shared_mutex.hpp> | |
31 #include <map> | |
32 #include <string> | |
33 | |
34 | |
35 /** | |
36 * As the static assets are gzipped by the "EmbedStaticAssets.py" | |
37 * script, we use a cache to maintain the uncompressed assets in order | |
38 * to avoid multiple gzip decodings. | |
39 **/ | |
40 class ResourcesCache : public boost::noncopyable | |
41 { | |
42 public: | |
43 class IHandler : public boost::noncopyable | |
44 { | |
45 public: | |
46 virtual ~IHandler() | |
47 { | |
48 } | |
49 | |
50 virtual void Apply(const std::string& resource) = 0; | |
51 }; | |
52 | |
53 private: | |
54 typedef std::map<std::string, std::string*> Content; | |
55 | |
56 boost::shared_mutex mutex_; | |
57 Content content_; | |
58 | |
59 class RestOutputHandler; | |
60 class StoreResourceIntoString; | |
61 | |
62 public: | |
63 ~ResourcesCache(); | |
64 | |
65 void Apply(IHandler& handler, | |
66 const std::string& path); | |
67 | |
68 void Answer(OrthancPluginRestOutput* output, | |
69 const std::string& path); | |
70 | |
71 void ReadResource(std::string& target, | |
72 const std::string& path); | |
73 }; |