Mercurial > hg > orthanc
annotate OrthancFramework/Sources/RestApi/RestApiHierarchy.h @ 5853:4d932683049d get-scu tip
very first implementation of C-Get SCU
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 29 Oct 2024 17:25:49 +0100 |
parents | f7adfb22e20e |
children |
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 |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
969 | 8 * |
9 * 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
|
10 * 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
|
11 * 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
|
12 * the License, or (at your option) any later version. |
969 | 13 * |
14 * This program is distributed in the hope that it will be useful, but | |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * 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
|
17 * Lesser General Public License for more details. |
969 | 18 * |
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
|
19 * 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
|
20 * 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
|
21 * <http://www.gnu.org/licenses/>. |
969 | 22 **/ |
23 | |
24 | |
25 #pragma once | |
26 | |
975 | 27 #include "RestApiGetCall.h" |
28 #include "RestApiPostCall.h" | |
29 #include "RestApiPutCall.h" | |
30 #include "RestApiDeleteCall.h" | |
969 | 31 |
978 | 32 #include <set> |
33 | |
969 | 34 namespace Orthanc |
35 { | |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
36 class ORTHANC_PUBLIC RestApiHierarchy : public boost::noncopyable |
969 | 37 { |
978 | 38 public: |
4026
05a363186da6
ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3992
diff
changeset
|
39 class ORTHANC_PUBLIC Resource : public boost::noncopyable |
969 | 40 { |
972 | 41 private: |
975 | 42 RestApiGetCall::Handler getHandler_; |
43 RestApiPostCall::Handler postHandler_; | |
44 RestApiPutCall::Handler putHandler_; | |
974 | 45 RestApiDeleteCall::Handler deleteHandler_; |
969 | 46 |
972 | 47 public: |
978 | 48 Resource(); |
972 | 49 |
4400 | 50 bool HasHandler(HttpMethod method) const; |
969 | 51 |
4300 | 52 void Register(RestApiGetCall::Handler handler); |
969 | 53 |
4300 | 54 void Register(RestApiPutCall::Handler handler); |
969 | 55 |
4300 | 56 void Register(RestApiPostCall::Handler handler); |
969 | 57 |
4300 | 58 void Register(RestApiDeleteCall::Handler handler); |
969 | 59 |
60 bool IsEmpty() const; | |
978 | 61 |
62 bool Handle(RestApiGetCall& call) const; | |
63 | |
64 bool Handle(RestApiPutCall& call) const; | |
65 | |
66 bool Handle(RestApiPostCall& call) const; | |
67 | |
68 bool Handle(RestApiDeleteCall& call) const; | |
969 | 69 }; |
70 | |
71 | |
978 | 72 class IVisitor : public boost::noncopyable |
73 { | |
74 public: | |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
75 virtual ~IVisitor() |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
76 { |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
77 } |
978 | 78 |
79 virtual bool Visit(const Resource& resource, | |
80 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
|
81 bool hasTrailing, |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4400
diff
changeset
|
82 // "uriArguments" only contains their name if using "ExploreAllResources()" |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4400
diff
changeset
|
83 const HttpToolbox::Arguments& uriArguments, |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4400
diff
changeset
|
84 // "trailing" is empty if using "ExploreAllResources()" |
978 | 85 const UriComponents& trailing) = 0; |
86 }; | |
87 | |
88 | |
89 private: | |
969 | 90 typedef std::map<std::string, RestApiHierarchy*> Children; |
91 | |
978 | 92 Resource handlers_; |
969 | 93 Children children_; |
94 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
|
95 Resource handlersWithTrailing_; |
969 | 96 |
97 static RestApiHierarchy& AddChild(Children& children, | |
98 const std::string& name); | |
99 | |
100 static void DeleteChildren(Children& children); | |
101 | |
102 template <typename Handler> | |
103 void RegisterInternal(const RestApiPath& path, | |
104 Handler handler, | |
105 size_t level); | |
106 | |
978 | 107 bool CanGenerateDirectory() const; |
108 | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4303
diff
changeset
|
109 bool LookupResource(HttpToolbox::Arguments& components, |
978 | 110 const UriComponents& uri, |
111 IVisitor& visitor, | |
112 size_t level); | |
969 | 113 |
114 bool GetDirectory(Json::Value& result, | |
115 const UriComponents& uri, | |
116 size_t level); | |
117 | |
118 public: | |
119 ~RestApiHierarchy(); | |
120 | |
970 | 121 void Register(const std::string& uri, |
974 | 122 RestApiGetCall::Handler handler); |
969 | 123 |
970 | 124 void Register(const std::string& uri, |
974 | 125 RestApiPutCall::Handler handler); |
969 | 126 |
970 | 127 void Register(const std::string& uri, |
974 | 128 RestApiPostCall::Handler handler); |
969 | 129 |
970 | 130 void Register(const std::string& uri, |
974 | 131 RestApiDeleteCall::Handler handler); |
969 | 132 |
133 void CreateSiteMap(Json::Value& target) const; | |
134 | |
135 bool GetDirectory(Json::Value& result, | |
4300 | 136 const UriComponents& uri); |
969 | 137 |
978 | 138 bool LookupResource(const UriComponents& uri, |
139 IVisitor& visitor); | |
969 | 140 |
978 | 141 void GetAcceptedMethods(std::set<HttpMethod>& methods, |
142 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
|
143 |
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
|
144 void ExploreAllResources(IVisitor& visitor, |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4400
diff
changeset
|
145 const UriComponents& path, |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4400
diff
changeset
|
146 const std::set<std::string>& uriArguments) const; |
969 | 147 }; |
148 } |