comparison Core/RestApi/RestApiHierarchy.h @ 975:c550e99c452b

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 30 Jun 2014 14:53:18 +0200
parents 83622b0f544c
children ce3106e5843f
comparison
equal deleted inserted replaced
974:83622b0f544c 975:c550e99c452b
30 **/ 30 **/
31 31
32 32
33 #pragma once 33 #pragma once
34 34
35 #include "RestApi.h" 35 #include "RestApiGetCall.h"
36 36 #include "RestApiPostCall.h"
37 #include "../OrthancException.h" 37 #include "RestApiPutCall.h"
38 38 #include "RestApiDeleteCall.h"
39 #include <list>
40 #include <set>
41 39
42 namespace Orthanc 40 namespace Orthanc
43 { 41 {
44 class RestApiHierarchy 42 class RestApiHierarchy
45 { 43 {
46 private: 44 private:
47 class Handlers 45 class Handlers
48 { 46 {
49 private: 47 private:
50 RestApiGetCall::Handler getHandler_; 48 RestApiGetCall::Handler getHandler_;
51 RestApiPostCall::Handler postHandler_; 49 RestApiPostCall::Handler postHandler_;
52 RestApiPutCall::Handler putHandler_; 50 RestApiPutCall::Handler putHandler_;
53 RestApiDeleteCall::Handler deleteHandler_; 51 RestApiDeleteCall::Handler deleteHandler_;
54 52
55 public: 53 public:
56 Handlers(); 54 Handlers();
57 55
90 88
91 89
92 typedef std::map<std::string, RestApiHierarchy*> Children; 90 typedef std::map<std::string, RestApiHierarchy*> Children;
93 typedef bool (*ResourceCallback) (Handlers& handlers, 91 typedef bool (*ResourceCallback) (Handlers& handlers,
94 const UriComponents& uri, 92 const UriComponents& uri,
95 const RestApiPath::Components& components, 93 const HttpHandler::Arguments& components,
96 const UriComponents& trailing, 94 const UriComponents& trailing,
97 void* call); 95 void* call);
98 96
99 Handlers handlers_; 97 Handlers handlers_;
100 Children children_; 98 Children children_;
110 template <typename Handler> 108 template <typename Handler>
111 void RegisterInternal(const RestApiPath& path, 109 void RegisterInternal(const RestApiPath& path,
112 Handler handler, 110 Handler handler,
113 size_t level); 111 size_t level);
114 112
115 bool LookupHandler(RestApiPath::Components& components, 113 bool LookupHandler(HttpHandler::Arguments& components,
116 const UriComponents& uri, 114 const UriComponents& uri,
117 ResourceCallback callback, 115 ResourceCallback callback,
118 size_t level, 116 size_t level,
119 void* call); 117 void* call);
120 118
122 const UriComponents& uri, 120 const UriComponents& uri,
123 size_t level); 121 size_t level);
124 122
125 static bool GetCallback(Handlers& handlers, 123 static bool GetCallback(Handlers& handlers,
126 const UriComponents& uri, 124 const UriComponents& uri,
127 const RestApiPath::Components& components, 125 const HttpHandler::Arguments& components,
128 const UriComponents& trailing, 126 const UriComponents& trailing,
129 void* call); 127 void* call);
130 128
131 static bool PostCallback(Handlers& handlers, 129 static bool PostCallback(Handlers& handlers,
132 const UriComponents& uri, 130 const UriComponents& uri,
133 const RestApiPath::Components& components, 131 const HttpHandler::Arguments& components,
134 const UriComponents& trailing, 132 const UriComponents& trailing,
135 void* call); 133 void* call);
136 134
137 static bool PutCallback(Handlers& handlers, 135 static bool PutCallback(Handlers& handlers,
138 const UriComponents& uri, 136 const UriComponents& uri,
139 const RestApiPath::Components& components, 137 const HttpHandler::Arguments& components,
140 const UriComponents& trailing, 138 const UriComponents& trailing,
141 void* call); 139 void* call);
142 140
143 static bool DeleteCallback(Handlers& handlers, 141 static bool DeleteCallback(Handlers& handlers,
144 const UriComponents& uri, 142 const UriComponents& uri,
145 const RestApiPath::Components& components, 143 const HttpHandler::Arguments& components,
146 const UriComponents& trailing, 144 const UriComponents& trailing,
147 void* call); 145 void* call);
148 146
149 147
150 public: 148 public: