Mercurial > hg > orthanc
annotate OrthancFramework/Sources/RestApi/RestApiHierarchy.h @ 4642:69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 28 Apr 2021 11:22:39 +0200 |
parents | d9473bd5ed43 |
children | 7053502fbf97 |
rev | line source |
---|---|
969 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
978
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4401
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
969 | 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:
4044
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:
4044
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:
4044
diff
changeset
|
10 * the License, or (at your option) any later version. |
969 | 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:
4044
diff
changeset
|
15 * Lesser General Public License for more details. |
969 | 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:
4044
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:
4044
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:
4044
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
969 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
975 | 25 #include "RestApiGetCall.h" |
26 #include "RestApiPostCall.h" | |
27 #include "RestApiPutCall.h" | |
28 #include "RestApiDeleteCall.h" | |
969 | 29 |
978 | 30 #include <set> |
31 | |
969 | 32 namespace Orthanc |
33 { | |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
34 class ORTHANC_PUBLIC RestApiHierarchy : public boost::noncopyable |
969 | 35 { |
978 | 36 public: |
4026
05a363186da6
ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3992
diff
changeset
|
37 class ORTHANC_PUBLIC Resource : public boost::noncopyable |
969 | 38 { |
972 | 39 private: |
975 | 40 RestApiGetCall::Handler getHandler_; |
41 RestApiPostCall::Handler postHandler_; | |
42 RestApiPutCall::Handler putHandler_; | |
974 | 43 RestApiDeleteCall::Handler deleteHandler_; |
969 | 44 |
972 | 45 public: |
978 | 46 Resource(); |
972 | 47 |
4400 | 48 bool HasHandler(HttpMethod method) const; |
969 | 49 |
4300 | 50 void Register(RestApiGetCall::Handler handler); |
969 | 51 |
4300 | 52 void Register(RestApiPutCall::Handler handler); |
969 | 53 |
4300 | 54 void Register(RestApiPostCall::Handler handler); |
969 | 55 |
4300 | 56 void Register(RestApiDeleteCall::Handler handler); |
969 | 57 |
58 bool IsEmpty() const; | |
978 | 59 |
60 bool Handle(RestApiGetCall& call) const; | |
61 | |
62 bool Handle(RestApiPutCall& call) const; | |
63 | |
64 bool Handle(RestApiPostCall& call) const; | |
65 | |
66 bool Handle(RestApiDeleteCall& call) const; | |
969 | 67 }; |
68 | |
69 | |
978 | 70 class IVisitor : public boost::noncopyable |
71 { | |
72 public: | |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
73 virtual ~IVisitor() |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
74 { |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
75 } |
978 | 76 |
77 virtual bool Visit(const Resource& resource, | |
78 const UriComponents& uri, | |
4399
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
79 bool hasTrailing, |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4400
diff
changeset
|
80 // "uriArguments" only contains their name if using "ExploreAllResources()" |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4400
diff
changeset
|
81 const HttpToolbox::Arguments& uriArguments, |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4400
diff
changeset
|
82 // "trailing" is empty if using "ExploreAllResources()" |
978 | 83 const UriComponents& trailing) = 0; |
84 }; | |
85 | |
86 | |
87 private: | |
969 | 88 typedef std::map<std::string, RestApiHierarchy*> Children; |
89 | |
978 | 90 Resource handlers_; |
969 | 91 Children children_; |
92 Children wildcardChildren_; | |
4399
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
93 Resource handlersWithTrailing_; |
969 | 94 |
95 static RestApiHierarchy& AddChild(Children& children, | |
96 const std::string& name); | |
97 | |
98 static void DeleteChildren(Children& children); | |
99 | |
100 template <typename Handler> | |
101 void RegisterInternal(const RestApiPath& path, | |
102 Handler handler, | |
103 size_t level); | |
104 | |
978 | 105 bool CanGenerateDirectory() const; |
106 | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4303
diff
changeset
|
107 bool LookupResource(HttpToolbox::Arguments& components, |
978 | 108 const UriComponents& uri, |
109 IVisitor& visitor, | |
110 size_t level); | |
969 | 111 |
112 bool GetDirectory(Json::Value& result, | |
113 const UriComponents& uri, | |
114 size_t level); | |
115 | |
116 public: | |
117 ~RestApiHierarchy(); | |
118 | |
970 | 119 void Register(const std::string& uri, |
974 | 120 RestApiGetCall::Handler handler); |
969 | 121 |
970 | 122 void Register(const std::string& uri, |
974 | 123 RestApiPutCall::Handler handler); |
969 | 124 |
970 | 125 void Register(const std::string& uri, |
974 | 126 RestApiPostCall::Handler handler); |
969 | 127 |
970 | 128 void Register(const std::string& uri, |
974 | 129 RestApiDeleteCall::Handler handler); |
969 | 130 |
131 void CreateSiteMap(Json::Value& target) const; | |
132 | |
133 bool GetDirectory(Json::Value& result, | |
4300 | 134 const UriComponents& uri); |
969 | 135 |
978 | 136 bool LookupResource(const UriComponents& uri, |
137 IVisitor& visitor); | |
969 | 138 |
978 | 139 void GetAcceptedMethods(std::set<HttpMethod>& methods, |
140 const UriComponents& uri); | |
4399
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
141 |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
142 void ExploreAllResources(IVisitor& visitor, |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4400
diff
changeset
|
143 const UriComponents& path, |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4400
diff
changeset
|
144 const std::set<std::string>& uriArguments) const; |
969 | 145 }; |
146 } |