Orfeo Toolbox  4.0
otbOpticalImageMetadataInterfaceFactory.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 // Optical sensors
30 
31 
32 #include "itkObjectFactoryBase.h"
33 #include "itkMutexLock.h"
34 #include "itkMutexLockHolder.h"
35 
36 namespace otb
37 {
41 {
42  RegisterBuiltInFactories();
43 
44  std::list<OpticalImageMetadataInterfacePointerType> possibleIMI;
45  std::list<itk::LightObject::Pointer> allobjects =
46  itk::ObjectFactoryBase::CreateAllInstance("OpticalImageMetadataInterface");
47  for (std::list<itk::LightObject::Pointer>::iterator i = allobjects.begin();
48  i != allobjects.end(); ++i)
49  {
50  OpticalImageMetadataInterface * io = dynamic_cast<OpticalImageMetadataInterface*>(i->GetPointer());
51  if (io)
52  {
53  possibleIMI.push_back(io);
54  }
55  else
56  {
57  itkGenericExceptionMacro(<< "Error OpticalImageMetadataInterface factory did not return an OpticalImageMetadataInterface: "
58  << (*i)->GetNameOfClass());
59  }
60  }
61  for (std::list<OpticalImageMetadataInterfacePointerType>::iterator k = possibleIMI.begin();
62  k != possibleIMI.end(); ++k)
63  {
64  (*k)->SetMetaDataDictionary(dict);
65  if ((*k)->CanRead())
66  {
67  return *k;
68  }
69  }
70 
72  return dynamic_cast<OpticalImageMetadataInterface*>(static_cast<OpticalDefaultImageMetadataInterface*>(defaultIMI));
73 }
74 
75 void
78 {
79  static bool firstTime = true;
80 
81  static itk::SimpleMutexLock mutex;
82  {
83  // This helper class makes sure the Mutex is unlocked
84  // in the event an exception is thrown.
86  if (firstTime)
87  {
94  firstTime = false;
95  }
96  }
97 }
98 
99 } // end namespace otb

Generated at Sat Mar 8 2014 16:12:14 for Orfeo Toolbox with doxygen 1.8.3.1