comparison OrthancServer/ServerIndex.cpp @ 226:8a26a8e85edf

refactoring to read files
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 30 Nov 2012 09:45:29 +0100
parents 4eb0c7ce86c9
children 8098448bd827
comparison
equal deleted inserted replaced
225:03aa59ecf6d8 226:8a26a8e85edf
30 **/ 30 **/
31 31
32 32
33 #include "ServerIndex.h" 33 #include "ServerIndex.h"
34 34
35 using namespace Orthanc;
36
37 #ifndef NOMINMAX 35 #ifndef NOMINMAX
38 #define NOMINMAX 36 #define NOMINMAX
39 #endif 37 #endif
40 38
41 #include "EmbeddedResources.h" 39 #include "EmbeddedResources.h"
42 #include "../Core/Toolbox.h" 40 #include "../Core/Toolbox.h"
43 #include "../Core/Uuid.h" 41 #include "../Core/Uuid.h"
44 #include "../Core/DicomFormat/DicomArray.h" 42 #include "../Core/DicomFormat/DicomArray.h"
45 #include "../Core/SQLite/Transaction.h" 43 #include "../Core/SQLite/Transaction.h"
46 #include "FromDcmtkBridge.h" 44 #include "FromDcmtkBridge.h"
45 #include "ServerContext.h"
47 46
48 #include <boost/lexical_cast.hpp> 47 #include <boost/lexical_cast.hpp>
49 #include <stdio.h> 48 #include <stdio.h>
50 #include <glog/logging.h> 49 #include <glog/logging.h>
51 50
54 namespace Internals 53 namespace Internals
55 { 54 {
56 class ServerIndexListener : public IServerIndexListener 55 class ServerIndexListener : public IServerIndexListener
57 { 56 {
58 private: 57 private:
59 FileStorage& fileStorage_; 58 ServerContext& context_;
60 bool hasRemainingLevel_; 59 bool hasRemainingLevel_;
61 ResourceType remainingType_; 60 ResourceType remainingType_;
62 std::string remainingPublicId_; 61 std::string remainingPublicId_;
63 62
64 public: 63 public:
65 ServerIndexListener(FileStorage& fileStorage) : 64 ServerIndexListener(ServerContext& context) :
66 fileStorage_(fileStorage), 65 context_(context),
67 hasRemainingLevel_(false) 66 hasRemainingLevel_(false)
68 { 67 {
69 assert(ResourceType_Patient < ResourceType_Study && 68 assert(ResourceType_Patient < ResourceType_Study &&
70 ResourceType_Study < ResourceType_Series && 69 ResourceType_Study < ResourceType_Series &&
71 ResourceType_Series < ResourceType_Instance); 70 ResourceType_Series < ResourceType_Instance);
98 } 97 }
99 98
100 virtual void SignalFileDeleted(const std::string& fileUuid) 99 virtual void SignalFileDeleted(const std::string& fileUuid)
101 { 100 {
102 assert(Toolbox::IsUuid(fileUuid)); 101 assert(Toolbox::IsUuid(fileUuid));
103 fileStorage_.Remove(fileUuid); 102 context_.RemoveFile(fileUuid);
104 } 103 }
105 104
106 bool HasRemainingLevel() const 105 bool HasRemainingLevel() const
107 { 106 {
108 return hasRemainingLevel_; 107 return hasRemainingLevel_;
178 db->FlushToDisk(); 177 db->FlushToDisk();
179 } 178 }
180 } 179 }
181 180
182 181
183 ServerIndex::ServerIndex(FileStorage& fileStorage, 182 ServerIndex::ServerIndex(ServerContext& context,
184 const std::string& dbPath) : mutex_() 183 const std::string& dbPath) : mutex_()
185 { 184 {
186 listener_.reset(new Internals::ServerIndexListener(fileStorage)); 185 listener_.reset(new Internals::ServerIndexListener(context));
187 186
188 if (dbPath == ":memory:") 187 if (dbPath == ":memory:")
189 { 188 {
190 db_.reset(new DatabaseWrapper(*listener_)); 189 db_.reset(new DatabaseWrapper(*listener_));
191 } 190 }