Mercurial > hg > orthanc
comparison OrthancServer/DicomProtocol/DicomServer.cpp @ 376:2cef9c2d4148
separate path for SQLite index, manual loading of external dictionaries
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 17 Apr 2013 11:13:51 +0200 |
parents | 8d3a0db39967 |
children | 4d5f0857ec9c |
comparison
equal
deleted
inserted
replaced
375:d1ea72f1c967 | 376:2cef9c2d4148 |
---|---|
37 #include "../../Core/Uuid.h" | 37 #include "../../Core/Uuid.h" |
38 #include "../Internals/CommandDispatcher.h" | 38 #include "../Internals/CommandDispatcher.h" |
39 #include "EmbeddedResources.h" | 39 #include "EmbeddedResources.h" |
40 | 40 |
41 #include <boost/thread.hpp> | 41 #include <boost/thread.hpp> |
42 #include <boost/filesystem.hpp> | |
42 #include <dcmtk/dcmdata/dcdict.h> | 43 #include <dcmtk/dcmdata/dcdict.h> |
43 #include <glog/logging.h> | 44 #include <glog/logging.h> |
45 | |
46 #if defined(__linux) | |
47 #include <cstdlib> | |
48 #endif | |
44 | 49 |
45 | 50 |
46 namespace Orthanc | 51 namespace Orthanc |
47 { | 52 { |
48 struct DicomServer::PImpl | 53 struct DicomServer::PImpl |
68 throw OrthancException(ErrorCode_InternalError); | 73 throw OrthancException(ErrorCode_InternalError); |
69 } | 74 } |
70 } | 75 } |
71 | 76 |
72 | 77 |
78 static void LoadExternalDictionary(DcmDataDictionary& dictionary, | |
79 const std::string& directory, | |
80 const std::string& filename) | |
81 { | |
82 boost::filesystem::path p = directory; | |
83 p = p / filename; | |
84 | |
85 if (!dictionary.loadDictionary(p.string().c_str())) | |
86 { | |
87 throw OrthancException(ErrorCode_InternalError); | |
88 } | |
89 } | |
90 | |
91 | |
73 | 92 |
74 void DicomServer::ServerThread(DicomServer* server) | 93 void DicomServer::ServerThread(DicomServer* server) |
75 { | 94 { |
76 /* Disable "gethostbyaddr" (which results in memory leaks) and use raw IP addresses */ | 95 /* Disable "gethostbyaddr" (which results in memory leaks) and use raw IP addresses */ |
77 dcmDisableGethostbyaddr.set(OFTrue); | 96 dcmDisableGethostbyaddr.set(OFTrue); |
78 | 97 |
98 dcmDataDict.clear(); | |
99 DcmDataDictionary& d = dcmDataDict.wrlock(); | |
100 | |
79 #if DCMTK_USE_EMBEDDED_DICTIONARIES == 1 | 101 #if DCMTK_USE_EMBEDDED_DICTIONARIES == 1 |
80 LOG(WARNING) << "Loading the embedded dictionaries"; | 102 LOG(WARNING) << "Loading the embedded dictionaries"; |
81 dcmDataDict.clear(); | |
82 DcmDataDictionary& d = dcmDataDict.wrlock(); | |
83 | |
84 /** | 103 /** |
85 * Do not load DICONDE dictionary, it breaks the other tags. The | 104 * Do not load DICONDE dictionary, it breaks the other tags. The |
86 * command "strace storescu 2>&1 |grep dic" shows that DICONDE | 105 * command "strace storescu 2>&1 |grep dic" shows that DICONDE |
87 * dictionary is not loaded by storescu. | 106 * dictionary is not loaded by storescu. |
88 **/ | 107 **/ |
89 //LoadEmbeddedDictionary(d, EmbeddedResources::DICTIONARY_DICONDE); | 108 //LoadEmbeddedDictionary(d, EmbeddedResources::DICTIONARY_DICONDE); |
90 | 109 |
91 LoadEmbeddedDictionary(d, EmbeddedResources::DICTIONARY_DICOM); | 110 LoadEmbeddedDictionary(d, EmbeddedResources::DICTIONARY_DICOM); |
92 LoadEmbeddedDictionary(d, EmbeddedResources::DICTIONARY_PRIVATE); | 111 LoadEmbeddedDictionary(d, EmbeddedResources::DICTIONARY_PRIVATE); |
112 | |
113 #elif defined(__linux) | |
114 std::string path = "/usr/share/dcmtk"; | |
115 | |
116 const char* env = std::getenv(DCM_DICT_ENVIRONMENT_VARIABLE); | |
117 if (env != NULL) | |
118 { | |
119 path = std::string(env); | |
120 } | |
121 | |
122 LoadExternalDictionary(d, path, "dicom.dic"); | |
123 LoadExternalDictionary(d, path, "private.dic"); | |
124 | |
125 #else | |
126 #error Support your platform here | |
127 #endif | |
128 | |
93 dcmDataDict.unlock(); | 129 dcmDataDict.unlock(); |
94 #endif | |
95 | 130 |
96 /* make sure data dictionary is loaded */ | 131 /* make sure data dictionary is loaded */ |
97 if (!dcmDataDict.isDictionaryLoaded()) | 132 if (!dcmDataDict.isDictionaryLoaded()) |
98 { | 133 { |
99 LOG(ERROR) << "No DICOM dictionary loaded, check environment variable: " << DCM_DICT_ENVIRONMENT_VARIABLE; | 134 LOG(ERROR) << "No DICOM dictionary loaded, check environment variable: " << DCM_DICT_ENVIRONMENT_VARIABLE; |