comparison OrthancServer/Sources/OrthancInitialization.cpp @ 5807:8279eaab0d1d attach-custom-data

merged default -> attach-custom-data
author Alain Mazy <am@orthanc.team>
date Tue, 24 Sep 2024 11:39:52 +0200
parents d7274e43ea7c f7adfb22e20e
children 023a99146dd0
comparison
equal deleted inserted replaced
5085:79f98ee4f04b 5807:8279eaab0d1d
1 /** 1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store 2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium 4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium 5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium 6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
7 * 8 *
8 * This program is free software: you can redistribute it and/or 9 * This program is free software: you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 10 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation, either version 3 of the 11 * published by the Free Software Foundation, either version 3 of the
11 * License, or (at your option) any later version. 12 * License, or (at your option) any later version.
49 50
50 #include <OrthancServerResources.h> 51 #include <OrthancServerResources.h>
51 52
52 #include <dcmtk/dcmnet/diutil.h> // For DCM_dcmnetLogger 53 #include <dcmtk/dcmnet/diutil.h> // For DCM_dcmnetLogger
53 54
55 #if ORTHANC_ENABLE_PLUGINS == 1
56 # if defined(__ORTHANC_FILE__)
57 // Prevents the system-wide Google Protobuf library from leaking the
58 // full path of this source file
59 # undef __FILE__
60 # define __FILE__ __ORTHANC_FILE__
61 # endif
62 # include <google/protobuf/any.h>
63 #endif
64
54 65
55 static const char* const STORAGE_DIRECTORY = "StorageDirectory"; 66 static const char* const STORAGE_DIRECTORY = "StorageDirectory";
56 static const char* const ORTHANC_STORAGE = "OrthancStorage"; 67 static const char* const ORTHANC_STORAGE = "OrthancStorage";
57 68
58 69
202 213
203 static void LoadMainDicomTags(const Json::Value& configuration) 214 static void LoadMainDicomTags(const Json::Value& configuration)
204 { 215 {
205 static const char* const EXTRA_MAIN_DICOM_TAGS = "ExtraMainDicomTags"; 216 static const char* const EXTRA_MAIN_DICOM_TAGS = "ExtraMainDicomTags";
206 217
218 DicomMap::ResetDefaultMainDicomTags();
219
207 if (configuration.type() != Json::objectValue || 220 if (configuration.type() != Json::objectValue ||
208 !configuration.isMember(EXTRA_MAIN_DICOM_TAGS) || 221 !configuration.isMember(EXTRA_MAIN_DICOM_TAGS) ||
209 configuration[EXTRA_MAIN_DICOM_TAGS].type() != Json::objectValue) 222 configuration[EXTRA_MAIN_DICOM_TAGS].type() != Json::objectValue)
210 { 223 {
211 return; 224 return;
233 const std::string& tagName = content[t].asString(); 246 const std::string& tagName = content[t].asString();
234 DicomTag tag(FromDcmtkBridge::ParseTag(tagName)); 247 DicomTag tag(FromDcmtkBridge::ParseTag(tagName));
235 248
236 if (DicomMap::IsComputedTag(tag)) 249 if (DicomMap::IsComputedTag(tag))
237 { 250 {
238 LOG(WARNING) << " - " << tagName << " can not be added in the Extra Main Dicom Tags since the value of this tag is computed when requested"; 251 LOG(WARNING) << " - " << tagName << " cannot be added in the Extra Main Dicom Tags since the value of this tag is computed when requested";
239 } 252 }
240 else 253 else
241 { 254 {
242 ValueRepresentation vr = FromDcmtkBridge::LookupValueRepresentation(tag); 255 ValueRepresentation vr = FromDcmtkBridge::LookupValueRepresentation(tag);
243 if (vr == ValueRepresentation_Sequence) 256 if (vr == ValueRepresentation_Sequence)
311 static const char* const MALLOC_ARENA_MAX = "MallocArenaMax"; 324 static const char* const MALLOC_ARENA_MAX = "MallocArenaMax";
312 static const char* const LOAD_PRIVATE_DICTIONARY = "LoadPrivateDictionary"; 325 static const char* const LOAD_PRIVATE_DICTIONARY = "LoadPrivateDictionary";
313 326
314 OrthancConfiguration::WriterLock lock; 327 OrthancConfiguration::WriterLock lock;
315 328
329 #if ORTHANC_ENABLE_PLUGINS == 1
330 GOOGLE_PROTOBUF_VERIFY_VERSION;
331 #endif
332
316 InitializeServerEnumerations(); 333 InitializeServerEnumerations();
317 334
318 // Read the user-provided configuration 335 // Read the user-provided configuration
319 lock.GetConfiguration().Read(configurationFile); 336 lock.GetConfiguration().Read(configurationFile);
320 337
352 369
353 LoadExternalDictionaries(lock.GetJson()); // New in Orthanc 1.9.4 370 LoadExternalDictionaries(lock.GetJson()); // New in Orthanc 1.9.4
354 LoadCustomDictionary(lock.GetJson()); 371 LoadCustomDictionary(lock.GetJson());
355 372
356 lock.GetConfiguration().LoadWarnings(); 373 lock.GetConfiguration().LoadWarnings();
374 lock.GetConfiguration().LoadJobsEngineThreadsCount();
357 375
358 LoadMainDicomTags(lock.GetJson()); // New in Orthanc 1.11.0 376 LoadMainDicomTags(lock.GetJson()); // New in Orthanc 1.11.0
359 377
360 lock.GetConfiguration().RegisterFont(ServerResources::FONT_UBUNTU_MONO_BOLD_16); 378 lock.GetConfiguration().RegisterFont(ServerResources::FONT_UBUNTU_MONO_BOLD_16);
361 379
362 #if HAVE_MALLOPT == 1 380 #if HAVE_MALLOPT == 1
363 // New in Orthanc 1.8.2 381 // New in Orthanc 1.8.2
364 // https://book.orthanc-server.com/faq/scalability.html#controlling-memory-usage 382 // https://orthanc.uclouvain.be/book/faq/scalability.html#controlling-memory-usage
365 unsigned int maxArena = lock.GetConfiguration().GetUnsignedIntegerParameter(MALLOC_ARENA_MAX, 5); 383 unsigned int maxArena = lock.GetConfiguration().GetUnsignedIntegerParameter(MALLOC_ARENA_MAX, 5);
366 if (maxArena != 0) 384 if (maxArena != 0)
367 { 385 {
368 // https://man7.org/linux/man-pages/man3/mallopt.3.html 386 // https://man7.org/linux/man-pages/man3/mallopt.3.html
369 LOG(INFO) << "Calling mallopt(M_ARENA_MAX, " << maxArena << ")"; 387 LOG(INFO) << "Calling mallopt(M_ARENA_MAX, " << maxArena << ")";
386 404
387 void OrthancFinalize() 405 void OrthancFinalize()
388 { 406 {
389 OrthancConfiguration::WriterLock lock; 407 OrthancConfiguration::WriterLock lock;
390 Orthanc::FinalizeFramework(); 408 Orthanc::FinalizeFramework();
409
410 #if ORTHANC_ENABLE_PLUGINS == 1
411 google::protobuf::ShutdownProtobufLibrary();
412 #endif
391 } 413 }
392 414
393 415
394 static IDatabaseWrapper* CreateSQLiteWrapper() 416 static IDatabaseWrapper* CreateSQLiteWrapper()
395 { 417 {