Mercurial > hg > orthanc
diff OrthancServer/main.cpp @ 224:4eb0c7ce86c9
refactoring for store
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 29 Nov 2012 22:22:00 +0100 |
parents | 96b7918a6a18 |
children | 1af3bc092db8 |
line wrap: on
line diff
--- a/OrthancServer/main.cpp Thu Nov 29 18:07:50 2012 +0100 +++ b/OrthancServer/main.cpp Thu Nov 29 22:22:00 2012 +0100 @@ -42,22 +42,20 @@ #include "../Core/HttpServer/MongooseServer.h" #include "DicomProtocol/DicomServer.h" #include "OrthancInitialization.h" - +#include "ServerContext.h" using namespace Orthanc; + class MyDicomStore : public IStoreRequestHandler { private: - ServerIndex& index_; - FileStorage storage_; + ServerContext& context_; public: - MyDicomStore(ServerIndex& index, - const std::string& path) : - index_(index), - storage_(path) + MyDicomStore(ServerContext& context) : + context_(context) { } @@ -68,9 +66,8 @@ { if (dicomFile.size() > 0) { - index_.Store(storage_, - reinterpret_cast<const char*>(&dicomFile[0]), dicomFile.size(), - dicomSummary, dicomJson, remoteAet); + context_.Store(reinterpret_cast<const char*>(&dicomFile[0]), dicomFile.size(), + dicomSummary, dicomJson, remoteAet); } } }; @@ -79,20 +76,16 @@ class MyDicomStoreFactory : public IStoreRequestHandlerFactory { private: - ServerIndex& index_; - std::string path_; + ServerContext& context_; public: - MyDicomStoreFactory(ServerIndex& index, - const std::string& path) : - index_(index), - path_(path) + MyDicomStoreFactory(ServerContext& context) : context_(context) { } virtual IStoreRequestHandler* ConstructStoreRequestHandler() { - return new MyDicomStore(index_, path_); + return new MyDicomStore(context_); } void Done() @@ -219,9 +212,8 @@ } boost::filesystem::path storageDirectory = GetGlobalStringParameter("StorageDirectory", "OrthancStorage"); - FileStorage storage(storageDirectory.string()); - ServerIndex index(storage, storageDirectory.string()); - MyDicomStoreFactory storeScp(index, storageDirectory.string()); + ServerContext context(storageDirectory); + MyDicomStoreFactory storeScp(context); { // DICOM server @@ -259,8 +251,8 @@ httpServer.RegisterHandler(new FilesystemHttpHandler("/app", ORTHANC_PATH "/OrthancExplorer")); #endif - httpServer.RegisterHandler(new OrthancRestApi2(index, storageDirectory.string())); - httpServer.RegisterHandler(new OrthancRestApi(index, storageDirectory.string())); + httpServer.RegisterHandler(new OrthancRestApi2(context)); + httpServer.RegisterHandler(new OrthancRestApi(context.GetIndex(), storageDirectory.string())); // GO !!! httpServer.Start();