Orfeo Toolbox  3.16
otbSarImageMetadataInterfaceFactory.cxx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 
19 
22 
23 // SAR Sensors
25 
26 #include "itkObjectFactoryBase.h"
27 #include "itkMutexLock.h"
28 #include "itkMutexLockHolder.h"
29 
30 namespace otb
31 {
35 {
36  RegisterBuiltInFactories();
37 
38  std::list<SarImageMetadataInterfacePointerType> possibleIMI;
39  std::list<itk::LightObject::Pointer> allobjects =
40  itk::ObjectFactoryBase::CreateAllInstance("SarImageMetadataInterface");
41  for (std::list<itk::LightObject::Pointer>::iterator i = allobjects.begin();
42  i != allobjects.end(); ++i)
43  {
44  SarImageMetadataInterface * io = dynamic_cast<SarImageMetadataInterface*>(i->GetPointer());
45  if (io)
46  {
47  possibleIMI.push_back(io);
48  }
49  else
50  {
51  itkGenericExceptionMacro(<< "Error SarImageMetadataInterface factory did not return an SarImageMetadataInterface: "
52  << (*i)->GetNameOfClass());
53  }
54  }
55  for (std::list<SarImageMetadataInterfacePointerType>::iterator k = possibleIMI.begin();
56  k != possibleIMI.end(); ++k)
57  {
58  (*k)->SetMetaDataDictionary(dict);
59  if ((*k)->CanRead())
60  {
61  return *k;
62  }
63  }
64 
66  return dynamic_cast<SarImageMetadataInterface*>(static_cast<SarDefaultImageMetadataInterface*>(defaultIMI));
67 }
68 
69 void
72 {
73  static bool firstTime = true;
74 
75  static itk::SimpleMutexLock mutex;
76  {
77  // This helper class makes sure the Mutex is unlocked
78  // in the event an exception is thrown.
80  if (firstTime)
81  {
83  firstTime = false;
84  }
85  }
86 }
87 
88 } // end namespace otb

Generated at Sun May 19 2013 00:47:48 for Orfeo Toolbox with doxygen 1.8.3.1