Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkDICOMTagScanner.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkDICOMTagScanner.h"
18 
19 itk::MutexLock::Pointer mitk::DICOMTagScanner::s_LocaleMutex = itk::MutexLock::New();
20 
22 {
23 }
24 
25 
27 {
28 }
29 
31 {
32  s_LocaleMutex->Lock();
33 
34  std::string currentCLocale = setlocale(LC_NUMERIC, nullptr);
35  m_ReplacedCLocales.push(currentCLocale);
36  setlocale(LC_NUMERIC, "C");
37 
38  std::locale currentCinLocale(std::cin.getloc());
39  m_ReplacedCinLocales.push(currentCinLocale);
40  std::locale l("C");
41  std::cin.imbue(l);
42 
43  s_LocaleMutex->Unlock();
44 }
45 
47 {
48  s_LocaleMutex->Lock();
49 
50  if (!m_ReplacedCLocales.empty())
51  {
52  setlocale(LC_NUMERIC, m_ReplacedCLocales.top().c_str());
53  m_ReplacedCLocales.pop();
54  }
55  else
56  {
57  MITK_WARN << "Mismatched PopLocale on DICOMITKSeriesGDCMReader.";
58  }
59 
60  if (!m_ReplacedCinLocales.empty())
61  {
62  std::cin.imbue(m_ReplacedCinLocales.top());
63  m_ReplacedCinLocales.pop();
64  }
65  else
66  {
67  MITK_WARN << "Mismatched PopLocale on DICOMITKSeriesGDCMReader.";
68  }
69 
70  s_LocaleMutex->Unlock();
71 }
72 
74 {
75  return setlocale(LC_NUMERIC, nullptr);
76 }
itk::SmartPointer< Self > Pointer
void PopLocale() const
Activate last remembered locale from locale stack "C" locale is required for correct parsing of numbe...
#define MITK_WARN
Definition: mitkLogMacros.h:23
void PushLocale() const
Remember current locale on stack, activate "C" locale. "C" locale is required for correct parsing of ...
static std::string GetActiveLocale()
Return active C locale.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.