Mercurial > hg > orthanc
comparison OrthancServer/ServerIndex.h @ 3160:fc9a4a2dad63
merge
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Thu, 24 Jan 2019 10:55:19 +0100 |
parents | beeeb6096f27 |
children | 8ea7c4546c3a |
comparison
equal
deleted
inserted
replaced
3159:4cfed5c2eacd | 3160:fc9a4a2dad63 |
---|---|
31 **/ | 31 **/ |
32 | 32 |
33 | 33 |
34 #pragma once | 34 #pragma once |
35 | 35 |
36 #include "../Core/Cache/LeastRecentlyUsedIndex.h" | |
37 #include "../Core/DicomFormat/DicomMap.h" | |
38 | |
39 #include "Database/IDatabaseWrapper.h" | |
40 | |
36 #include <boost/thread.hpp> | 41 #include <boost/thread.hpp> |
37 #include <boost/noncopyable.hpp> | 42 #include <boost/noncopyable.hpp> |
38 #include "../Core/Cache/LeastRecentlyUsedIndex.h" | |
39 #include "../Core/SQLite/Connection.h" | |
40 #include "../Core/DicomFormat/DicomMap.h" | |
41 #include "ServerEnumerations.h" | |
42 | |
43 #include "IDatabaseWrapper.h" | |
44 | 43 |
45 namespace Orthanc | 44 namespace Orthanc |
46 { | 45 { |
47 class LookupResource; | 46 class DatabaseLookup; |
48 class ServerContext; | |
49 class DicomInstanceToStore; | 47 class DicomInstanceToStore; |
50 class ParsedDicomFile; | 48 class ParsedDicomFile; |
49 class ServerContext; | |
51 | 50 |
52 class ServerIndex : public boost::noncopyable | 51 class ServerIndex : public boost::noncopyable |
53 { | 52 { |
54 public: | 53 public: |
55 typedef std::list<FileInfo> Attachments; | 54 typedef std::list<FileInfo> Attachments; |
57 | 56 |
58 private: | 57 private: |
59 class Listener; | 58 class Listener; |
60 class Transaction; | 59 class Transaction; |
61 class UnstableResourcePayload; | 60 class UnstableResourcePayload; |
61 class MainDicomTagsRegistry; | |
62 | 62 |
63 bool done_; | 63 bool done_; |
64 boost::mutex mutex_; | 64 boost::mutex mutex_; |
65 boost::thread flushThread_; | 65 boost::thread flushThread_; |
66 boost::thread unstableResourcesMonitorThread_; | 66 boost::thread unstableResourcesMonitorThread_; |
67 | 67 |
68 std::auto_ptr<Listener> listener_; | 68 std::auto_ptr<Listener> listener_; |
69 IDatabaseWrapper& db_; | 69 IDatabaseWrapper& db_; |
70 LeastRecentlyUsedIndex<int64_t, UnstableResourcePayload> unstableResources_; | 70 LeastRecentlyUsedIndex<int64_t, UnstableResourcePayload> unstableResources_; |
71 | 71 |
72 uint64_t currentStorageSize_; | |
73 uint64_t maximumStorageSize_; | 72 uint64_t maximumStorageSize_; |
74 unsigned int maximumPatients_; | 73 unsigned int maximumPatients_; |
75 bool overwrite_; | 74 bool overwrite_; |
75 std::auto_ptr<MainDicomTagsRegistry> mainDicomTagsRegistry_; | |
76 | 76 |
77 static void FlushThread(ServerIndex* that, | 77 static void FlushThread(ServerIndex* that, |
78 unsigned int threadSleep); | 78 unsigned int threadSleep); |
79 | 79 |
80 static void UnstableResourcesMonitorThread(ServerIndex* that, | 80 static void UnstableResourcesMonitorThread(ServerIndex* that, |
114 void LogChange(int64_t internalId, | 114 void LogChange(int64_t internalId, |
115 ChangeType changeType, | 115 ChangeType changeType, |
116 ResourceType resourceType, | 116 ResourceType resourceType, |
117 const std::string& publicId); | 117 const std::string& publicId); |
118 | 118 |
119 void SignalNewResource(ChangeType changeType, | |
120 ResourceType level, | |
121 const std::string& publicId, | |
122 int64_t internalId); | |
123 | |
119 uint64_t IncrementGlobalSequenceInternal(GlobalProperty property); | 124 uint64_t IncrementGlobalSequenceInternal(GlobalProperty property); |
120 | 125 |
121 int64_t CreateResource(const std::string& publicId, | 126 void NormalizeLookup(std::vector<DatabaseConstraint>& target, |
122 ResourceType type); | 127 const DatabaseLookup& source, |
123 | 128 ResourceType level) const; |
124 void SetInstanceMetadata(std::map<MetadataType, std::string>& instanceMetadata, | 129 |
125 int64_t instance, | 130 SeriesStatus GetSeriesStatus(int64_t id, |
126 MetadataType metadata, | 131 int64_t expectedNumberOfInstances); |
127 const std::string& value); | |
128 | 132 |
129 public: | 133 public: |
130 ServerIndex(ServerContext& context, | 134 ServerIndex(ServerContext& context, |
131 IDatabaseWrapper& database, | 135 IDatabaseWrapper& database, |
132 unsigned int threadSleep); | 136 unsigned int threadSleep); |
248 /* out */ unsigned int& countInstances, | 252 /* out */ unsigned int& countInstances, |
249 /* out */ uint64_t& dicomDiskSize, | 253 /* out */ uint64_t& dicomDiskSize, |
250 /* out */ uint64_t& dicomUncompressedSize, | 254 /* out */ uint64_t& dicomUncompressedSize, |
251 const std::string& publicId); | 255 const std::string& publicId); |
252 | 256 |
253 void LookupIdentifierExact(std::list<std::string>& result, | 257 void LookupIdentifierExact(std::vector<std::string>& result, |
254 ResourceType level, | 258 ResourceType level, |
255 const DicomTag& tag, | 259 const DicomTag& tag, |
256 const std::string& value); | 260 const std::string& value); |
257 | 261 |
258 StoreStatus AddAttachment(const FileInfo& attachment, | 262 StoreStatus AddAttachment(const FileInfo& attachment, |
282 bool LookupResourceType(ResourceType& type, | 286 bool LookupResourceType(ResourceType& type, |
283 const std::string& publicId); | 287 const std::string& publicId); |
284 | 288 |
285 unsigned int GetDatabaseVersion(); | 289 unsigned int GetDatabaseVersion(); |
286 | 290 |
287 void FindCandidates(std::vector<std::string>& resources, | |
288 std::vector<std::string>& instances, | |
289 const ::Orthanc::LookupResource& lookup); | |
290 | |
291 bool LookupParent(std::string& target, | 291 bool LookupParent(std::string& target, |
292 const std::string& publicId, | 292 const std::string& publicId, |
293 ResourceType parentType); | 293 ResourceType parentType); |
294 | 294 |
295 void ReconstructInstance(ParsedDicomFile& dicom); | 295 void ReconstructInstance(ParsedDicomFile& dicom); |
296 | |
297 void ApplyLookupResources(std::vector<std::string>& resourcesId, | |
298 std::vector<std::string>* instancesId, // Can be NULL if not needed | |
299 const DatabaseLookup& lookup, | |
300 ResourceType queryLevel, | |
301 size_t limit); | |
296 }; | 302 }; |
297 } | 303 } |