comparison OrthancServer/DicomProtocol/DicomServer.cpp @ 291:4d7469f72a0b

embedding of dicom dictionaries
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 14 Dec 2012 15:15:48 +0100
parents 0e97abc7b950
children 6c4f6229aad7
comparison
equal deleted inserted replaced
290:b3322636b06d 291:4d7469f72a0b
32 32
33 #include "DicomServer.h" 33 #include "DicomServer.h"
34 34
35 #include "../../Core/OrthancException.h" 35 #include "../../Core/OrthancException.h"
36 #include "../../Core/Toolbox.h" 36 #include "../../Core/Toolbox.h"
37 #include "../../Core/Uuid.h"
37 #include "../Internals/CommandDispatcher.h" 38 #include "../Internals/CommandDispatcher.h"
39 #include "EmbeddedResources.h"
38 40
39 #include <boost/thread.hpp> 41 #include <boost/thread.hpp>
40 #include <dcmtk/dcmdata/dcdict.h> 42 #include <dcmtk/dcmdata/dcdict.h>
41 #include <glog/logging.h> 43 #include <glog/logging.h>
42 44
49 51
50 //std::set< 52 //std::set<
51 }; 53 };
52 54
53 55
56 static void LoadEmbeddedDictionary(DcmDataDictionary& dictionary,
57 EmbeddedResources::FileResourceId resource)
58 {
59 Toolbox::TemporaryFile tmp;
60
61 FILE* fp = fopen(tmp.GetPath().c_str(), "wb");
62 fwrite(EmbeddedResources::GetFileResourceBuffer(resource),
63 EmbeddedResources::GetFileResourceSize(resource), 1, fp);
64 fclose(fp);
65
66 if (!dictionary.loadDictionary(tmp.GetPath().c_str()))
67 {
68 throw OrthancException(ErrorCode_InternalError);
69 }
70 }
71
72
73
54 void DicomServer::ServerThread(DicomServer* server) 74 void DicomServer::ServerThread(DicomServer* server)
55 { 75 {
56 /* Disable "gethostbyaddr" (which results in memory leaks) and use raw IP addresses */ 76 /* Disable "gethostbyaddr" (which results in memory leaks) and use raw IP addresses */
57 dcmDisableGethostbyaddr.set(OFTrue); 77 dcmDisableGethostbyaddr.set(OFTrue);
58 78
79 #if ORTHANC_STANDALONE == 1
80 LOG(WARNING) << "Loading the embedded dictionaries";
81 dcmDataDict.clear();
82 DcmDataDictionary& d = dcmDataDict.wrlock();
83 LoadEmbeddedDictionary(d, EmbeddedResources::DICTIONARY_DICOM);
84 LoadEmbeddedDictionary(d, EmbeddedResources::DICTIONARY_PRIVATE);
85 LoadEmbeddedDictionary(d, EmbeddedResources::DICTIONARY_DICONDE);
86 dcmDataDict.unlock();
87 #endif
88
59 /* make sure data dictionary is loaded */ 89 /* make sure data dictionary is loaded */
60 if (!dcmDataDict.isDictionaryLoaded()) 90 if (!dcmDataDict.isDictionaryLoaded())
61 { 91 {
62 LOG(ERROR) << "no data dictionary loaded, check environment variable: " << DCM_DICT_ENVIRONMENT_VARIABLE; 92 LOG(ERROR) << "no data dictionary loaded, check environment variable: " << DCM_DICT_ENVIRONMENT_VARIABLE;
93 throw OrthancException(ErrorCode_InternalError);
63 } 94 }
64 95
65 /* initialize network, i.e. create an instance of T_ASC_Network*. */ 96 /* initialize network, i.e. create an instance of T_ASC_Network*. */
66 T_ASC_Network *net; 97 T_ASC_Network *net;
67 OFCondition cond = ASC_initializeNetwork 98 OFCondition cond = ASC_initializeNetwork