Mercurial > hg > orthanc
comparison Core/RestApi/RestApi.h @ 210:96b7918a6a18
start of the refactoring of the Orthanc REST API
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 28 Nov 2012 18:03:44 +0100 |
parents | 9960642f0f45 |
children | f276b175dcaf |
comparison
equal
deleted
inserted
replaced
209:9960642f0f45 | 210:96b7918a6a18 |
---|---|
30 **/ | 30 **/ |
31 | 31 |
32 | 32 |
33 #pragma once | 33 #pragma once |
34 | 34 |
35 #include "../IDynamicObject.h" | |
36 #include "../HttpServer/HttpHandler.h" | 35 #include "../HttpServer/HttpHandler.h" |
37 #include "RestApiPath.h" | 36 #include "RestApiPath.h" |
38 #include "RestApiOutput.h" | 37 #include "RestApiOutput.h" |
39 | 38 |
40 namespace Orthanc | 39 namespace Orthanc |
46 { | 45 { |
47 friend class RestApi; | 46 friend class RestApi; |
48 | 47 |
49 private: | 48 private: |
50 RestApiOutput* output_; | 49 RestApiOutput* output_; |
51 IDynamicObject* context_; | 50 RestApi* context_; |
52 const HttpHandler::Arguments* httpHeaders_; | 51 const HttpHandler::Arguments* httpHeaders_; |
53 const RestApiPath::Components* uriComponents_; | 52 const RestApiPath::Components* uriComponents_; |
54 const UriComponents* trailing_; | 53 const UriComponents* trailing_; |
55 | 54 |
56 public: | 55 public: |
57 RestApiOutput& GetOutput() | 56 RestApiOutput& GetOutput() |
58 { | 57 { |
59 return *output_; | 58 return *output_; |
60 } | 59 } |
61 | 60 |
62 IDynamicObject* GetContext() | 61 RestApi& GetContext() |
63 { | 62 { |
64 return context_; | 63 return *context_; |
65 } | 64 } |
66 | 65 |
67 const HttpHandler::Arguments& GetHttpHeaders() const | 66 const HttpHandler::Arguments& GetHttpHeaders() const |
68 { | 67 { |
69 return *httpHeaders_; | 68 return *httpHeaders_; |
147 typedef std::list< std::pair<RestApiPath*, GetHandler> > GetHandlers; | 146 typedef std::list< std::pair<RestApiPath*, GetHandler> > GetHandlers; |
148 typedef std::list< std::pair<RestApiPath*, PutHandler> > PutHandlers; | 147 typedef std::list< std::pair<RestApiPath*, PutHandler> > PutHandlers; |
149 typedef std::list< std::pair<RestApiPath*, PostHandler> > PostHandlers; | 148 typedef std::list< std::pair<RestApiPath*, PostHandler> > PostHandlers; |
150 typedef std::list< std::pair<RestApiPath*, DeleteHandler> > DeleteHandlers; | 149 typedef std::list< std::pair<RestApiPath*, DeleteHandler> > DeleteHandlers; |
151 | 150 |
152 // CAUTION: PLEASE INTRODUCE MUTEX BETWEEN CONTEXTS !!! | |
153 std::auto_ptr<IDynamicObject> context_; | |
154 | |
155 GetHandlers getHandlers_; | 151 GetHandlers getHandlers_; |
156 PutHandlers putHandlers_; | 152 PutHandlers putHandlers_; |
157 PostHandlers postHandlers_; | 153 PostHandlers postHandlers_; |
158 DeleteHandlers deleteHandlers_; | 154 DeleteHandlers deleteHandlers_; |
159 | 155 |
165 std::string GetAcceptedMethods(const UriComponents& uri); | 161 std::string GetAcceptedMethods(const UriComponents& uri); |
166 | 162 |
167 public: | 163 public: |
168 RestApi() | 164 RestApi() |
169 { | 165 { |
170 } | |
171 | |
172 void SetContext(IDynamicObject* context) // This takes the ownership | |
173 { | |
174 context_.reset(context); | |
175 } | 166 } |
176 | 167 |
177 ~RestApi(); | 168 ~RestApi(); |
178 | 169 |
179 virtual bool IsServedUri(const UriComponents& uri); | 170 virtual bool IsServedUri(const UriComponents& uri); |