comparison OrthancServer/main.cpp @ 387:ff647eedfbe1

enabling of Find/Move commands
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 22 Apr 2013 15:59:33 +0200
parents 2cef9c2d4148
children a5ba074a613d
comparison
equal deleted inserted replaced
385:dfbd3989a3f9 387:ff647eedfbe1
37 #include <boost/algorithm/string/predicate.hpp> 37 #include <boost/algorithm/string/predicate.hpp>
38 38
39 #include "../Core/HttpServer/EmbeddedResourceHttpHandler.h" 39 #include "../Core/HttpServer/EmbeddedResourceHttpHandler.h"
40 #include "../Core/HttpServer/FilesystemHttpHandler.h" 40 #include "../Core/HttpServer/FilesystemHttpHandler.h"
41 #include "../Core/HttpServer/MongooseServer.h" 41 #include "../Core/HttpServer/MongooseServer.h"
42 #include "../Core/DicomFormat/DicomArray.h"
42 #include "DicomProtocol/DicomServer.h" 43 #include "DicomProtocol/DicomServer.h"
43 #include "OrthancInitialization.h" 44 #include "OrthancInitialization.h"
44 #include "ServerContext.h" 45 #include "ServerContext.h"
45 46
46 using namespace Orthanc; 47 using namespace Orthanc;
47 48
48 49
49 50
50 class MyDicomStore : public IStoreRequestHandler 51 class MyStoreRequestHandler : public IStoreRequestHandler
51 { 52 {
52 private: 53 private:
53 ServerContext& context_; 54 ServerContext& context_;
54 55
55 public: 56 public:
56 MyDicomStore(ServerContext& context) : 57 MyStoreRequestHandler(ServerContext& context) :
57 context_(context) 58 context_(context)
58 { 59 {
59 } 60 }
60 61
61 virtual void Handle(const std::string& dicomFile, 62 virtual void Handle(const std::string& dicomFile,
69 } 70 }
70 } 71 }
71 }; 72 };
72 73
73 74
74 class MyDicomStoreFactory : public IStoreRequestHandlerFactory 75 class MyFindRequestHandler : public IFindRequestHandler
75 { 76 {
76 private: 77 private:
77 ServerContext& context_; 78 ServerContext& context_;
78 79
79 public: 80 public:
80 MyDicomStoreFactory(ServerContext& context) : context_(context) 81 MyFindRequestHandler(ServerContext& context) :
82 context_(context)
83 {
84 }
85
86 virtual void Handle(const DicomMap& input,
87 DicomFindAnswers& answers)
88 {
89 printf("FindRequest\n");
90 DicomArray a(input);
91 a.Print(stdout);
92 }
93 };
94
95
96 class MyMoveRequestHandler : public IMoveRequestHandler
97 {
98 private:
99 ServerContext& context_;
100
101 public:
102 MyMoveRequestHandler(ServerContext& context) :
103 context_(context)
104 {
105 }
106
107 public:
108 virtual IMoveRequestIterator* Handle(const std::string& target,
109 const DicomMap& input)
110 {
111 printf("MoveRequest\n");
112 return NULL;
113 }
114 };
115
116
117 class MyDicomServerFactory :
118 public IStoreRequestHandlerFactory,
119 public IFindRequestHandlerFactory,
120 public IMoveRequestHandlerFactory
121 {
122 private:
123 ServerContext& context_;
124
125 public:
126 MyDicomServerFactory(ServerContext& context) : context_(context)
81 { 127 {
82 } 128 }
83 129
84 virtual IStoreRequestHandler* ConstructStoreRequestHandler() 130 virtual IStoreRequestHandler* ConstructStoreRequestHandler()
85 { 131 {
86 return new MyDicomStore(context_); 132 return new MyStoreRequestHandler(context_);
133 }
134
135 virtual IFindRequestHandler* ConstructFindRequestHandler()
136 {
137 return new MyFindRequestHandler(context_);
138 }
139
140 virtual IMoveRequestHandler* ConstructMoveRequestHandler()
141 {
142 return new MyMoveRequestHandler(context_);
87 } 143 }
88 144
89 void Done() 145 void Done()
90 { 146 {
91 //index_.db().Execute("DELETE FROM Studies");
92 } 147 }
93 }; 148 };
94 149
95 150
96 void PrintHelp(char* path) 151 void PrintHelp(char* path)
235 catch (...) 290 catch (...)
236 { 291 {
237 context.GetIndex().SetMaximumStorageSize(0); 292 context.GetIndex().SetMaximumStorageSize(0);
238 } 293 }
239 294
240 MyDicomStoreFactory storeScp(context); 295 MyDicomServerFactory serverFactory(context);
296
241 297
242 { 298 {
243 // DICOM server 299 // DICOM server
244 DicomServer dicomServer; 300 DicomServer dicomServer;
245 dicomServer.SetCalledApplicationEntityTitleCheck(GetGlobalBoolParameter("DicomCheckCalledAet", false)); 301 dicomServer.SetCalledApplicationEntityTitleCheck(GetGlobalBoolParameter("DicomCheckCalledAet", false));
246 dicomServer.SetStoreRequestHandlerFactory(storeScp); 302 dicomServer.SetStoreRequestHandlerFactory(serverFactory);
303 dicomServer.SetMoveRequestHandlerFactory(serverFactory);
304 dicomServer.SetFindRequestHandlerFactory(serverFactory);
247 dicomServer.SetPortNumber(GetGlobalIntegerParameter("DicomPort", 4242)); 305 dicomServer.SetPortNumber(GetGlobalIntegerParameter("DicomPort", 4242));
248 dicomServer.SetApplicationEntityTitle(GetGlobalStringParameter("DicomAet", "ORTHANC")); 306 dicomServer.SetApplicationEntityTitle(GetGlobalStringParameter("DicomAet", "ORTHANC"));
249 307
250 // HTTP server 308 // HTTP server
251 MongooseServer httpServer; 309 MongooseServer httpServer;
286 344
287 // Stop 345 // Stop
288 LOG(WARNING) << "Orthanc is stopping"; 346 LOG(WARNING) << "Orthanc is stopping";
289 } 347 }
290 348
291 storeScp.Done(); 349 serverFactory.Done();
292 } 350 }
293 catch (OrthancException& e) 351 catch (OrthancException& e)
294 { 352 {
295 LOG(ERROR) << "EXCEPTION [" << e.What() << "]"; 353 LOG(ERROR) << "EXCEPTION [" << e.What() << "]";
296 status = -1; 354 status = -1;