comparison OrthancServer/ServerContext.h @ 948:e57e08ed510f dicom-rt

integration mainline -> dicom-rt
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 Jun 2014 13:57:05 +0200
parents 8cfc6119a5bd d466b3606aca
children
comparison
equal deleted inserted replaced
767:c19552f604d5 948:e57e08ed510f
36 #include "../Core/FileStorage/CompressedFileStorageAccessor.h" 36 #include "../Core/FileStorage/CompressedFileStorageAccessor.h"
37 #include "../Core/FileStorage/FileStorage.h" 37 #include "../Core/FileStorage/FileStorage.h"
38 #include "../Core/RestApi/RestApiOutput.h" 38 #include "../Core/RestApi/RestApiOutput.h"
39 #include "../Core/Lua/LuaContext.h" 39 #include "../Core/Lua/LuaContext.h"
40 #include "ServerIndex.h" 40 #include "ServerIndex.h"
41 #include "FromDcmtkBridge.h" 41 #include "ParsedDicomFile.h"
42 42 #include "DicomProtocol/ReusableDicomUserConnection.h"
43 #include <boost/thread.hpp>
44 43
45 namespace Orthanc 44 namespace Orthanc
46 { 45 {
47 /** 46 /**
48 * This class is responsible for maintaining the storage area on the 47 * This class is responsible for maintaining the storage area on the
63 } 62 }
64 63
65 virtual IDynamicObject* Provide(const std::string& id); 64 virtual IDynamicObject* Provide(const std::string& id);
66 }; 65 };
67 66
68 boost::mutex cacheMutex_;
69
70 FileStorage storage_; 67 FileStorage storage_;
71 ServerIndex index_; 68 ServerIndex index_;
72 CompressedFileStorageAccessor accessor_; 69 CompressedFileStorageAccessor accessor_;
73 bool compressionEnabled_; 70 bool compressionEnabled_;
74 71
75 DicomCacheProvider provider_; 72 DicomCacheProvider provider_;
73 boost::mutex dicomCacheMutex_;
76 MemoryCache dicomCache_; 74 MemoryCache dicomCache_;
75 ReusableDicomUserConnection scu_;
77 76
78 LuaContext lua_; 77 LuaContext lua_;
79 78
80 public: 79 public:
80 class DicomCacheLocker
81 {
82 private:
83 ServerContext& that_;
84 ParsedDicomFile *dicom_;
85
86 public:
87 DicomCacheLocker(ServerContext& that,
88 const std::string& instancePublicId);
89
90 ~DicomCacheLocker();
91
92 ParsedDicomFile& GetDicom()
93 {
94 return *dicom_;
95 }
96 };
97
81 ServerContext(const boost::filesystem::path& storagePath, 98 ServerContext(const boost::filesystem::path& storagePath,
82 const boost::filesystem::path& indexPath); 99 const boost::filesystem::path& indexPath);
83 100
84 ServerIndex& GetIndex() 101 ServerIndex& GetIndex()
85 { 102 {
105 const DicomMap& dicomSummary, 122 const DicomMap& dicomSummary,
106 const Json::Value& dicomJson, 123 const Json::Value& dicomJson,
107 const std::string& remoteAet); 124 const std::string& remoteAet);
108 125
109 StoreStatus Store(std::string& resultPublicId, 126 StoreStatus Store(std::string& resultPublicId,
110 DcmFileFormat& dicomInstance, 127 ParsedDicomFile& dicomInstance,
111 const char* dicomBuffer, 128 const char* dicomBuffer,
112 size_t dicomSize); 129 size_t dicomSize);
113 130
114 StoreStatus Store(std::string& resultPublicId, 131 StoreStatus Store(std::string& resultPublicId,
115 DcmFileFormat& dicomInstance); 132 ParsedDicomFile& dicomInstance);
116 133
117 StoreStatus Store(std::string& resultPublicId, 134 StoreStatus Store(std::string& resultPublicId,
118 const char* dicomBuffer, 135 const char* dicomBuffer,
119 size_t dicomSize); 136 size_t dicomSize);
120 137
121 StoreStatus Store(std::string& resultPublicId, 138 StoreStatus Store(std::string& resultPublicId,
122 const std::string& dicomContent) 139 const std::string& dicomContent);
123 {
124 if (dicomContent.size() == 0)
125 return Store(resultPublicId, NULL, 0);
126 else
127 return Store(resultPublicId, &dicomContent[0], dicomContent.size());
128 }
129 140
130 void AnswerDicomFile(RestApiOutput& output, 141 void AnswerDicomFile(RestApiOutput& output,
131 const std::string& instancePublicId, 142 const std::string& instancePublicId,
132 FileContentType content); 143 FileContentType content);
133 144
138 void ReadFile(std::string& result, 149 void ReadFile(std::string& result,
139 const std::string& instancePublicId, 150 const std::string& instancePublicId,
140 FileContentType content, 151 FileContentType content,
141 bool uncompressIfNeeded = true); 152 bool uncompressIfNeeded = true);
142 153
143 // TODO IMPLEMENT MULTITHREADING FOR THIS METHOD
144 ParsedDicomFile& GetDicomFile(const std::string& instancePublicId);
145
146 boost::mutex& GetDicomFileMutex()
147 {
148 // TODO IMPROVE MULTITHREADING
149 // Every call to "ParsedDicomFile" must lock this mutex!!!
150 return cacheMutex_;
151 }
152
153 LuaContext& GetLuaContext() 154 LuaContext& GetLuaContext()
154 { 155 {
155 return lua_; 156 return lua_;
156 } 157 }
157 158
159 160
160 bool IsStoreMD5ForAttachments() const 161 bool IsStoreMD5ForAttachments() const
161 { 162 {
162 return accessor_.IsStoreMD5(); 163 return accessor_.IsStoreMD5();
163 } 164 }
165
166 ReusableDicomUserConnection& GetReusableDicomUserConnection()
167 {
168 return scu_;
169 }
164 }; 170 };
165 } 171 }