Orfeo Toolbox  3.16
itkTransformIOFactory.cxx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkTransformIOFactory.cxx,v $
5  Language: C++
6  Date: $Date: 2007-08-09 15:16:00 $
7  Version: $Revision: 1.1 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifdef _MSC_VER
18 #pragma warning ( disable : 4786 )
19 #endif
20 
21 #include "itkTransformIOFactory.h"
24 
25 #include "itkMutexLock.h"
26 #include "itkMutexLockHolder.h"
27 
28 namespace itk
29 {
30 
33 {
34 
36 
37  std::list<TransformIOBase::Pointer> possibleTransformIO;
38  std::list<LightObject::Pointer> allobjects =
39  ObjectFactoryBase::CreateAllInstance("itkTransformIOBase");
40  for(std::list<LightObject::Pointer>::iterator i = allobjects.begin();
41  i != allobjects.end(); ++i)
42  {
43  TransformIOBase* io = dynamic_cast<TransformIOBase*>(i->GetPointer());
44  if(io)
45  {
46  possibleTransformIO.push_back(io);
47  }
48  else
49  {
50  std::cerr << "Error TransformIO factory did not return an TransformIOBase: "
51  << (*i)->GetNameOfClass()
52  << std::endl;
53  }
54  }
55  for(std::list<TransformIOBase::Pointer>::iterator k = possibleTransformIO.begin();
56  k != possibleTransformIO.end(); ++k)
57  {
58  if( mode == ReadMode )
59  {
60  if((*k)->CanReadFile(path))
61  {
62  return *k;
63  }
64  }
65  else if( mode == WriteMode )
66  {
67  if((*k)->CanWriteFile(path))
68  {
69  return *k;
70  }
71 
72  }
73  }
74  return 0;
75 }
76 
77 void
79 {
80  static bool firstTime = true;
81 
82  static SimpleMutexLock mutex;
83  {
84  // This helper class makes sure the Mutex is unlocked
85  // in the event an exception is thrown.
86  MutexLockHolder<SimpleMutexLock> mutexHolder( mutex );
87  if( firstTime )
88  {
89  // ObjectFactoryBase::RegisterFactory( GDCMTransformIOFactory::New() );
92  firstTime = false;
93  }
94  }
95 }
96 
97 } // end namespace itk

Generated at Sun Feb 3 2013 00:10:18 for Orfeo Toolbox with doxygen 1.8.1.1